You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
848 B
JavaScript
28 lines
848 B
JavaScript
"use strict";
|
|
|
|
// Simple data type to represent a query path and corresponding schema path tied together, because these are basically always used together, and it would bloat up the implementation code otherwise
|
|
|
|
function createInstance({ queryPath, schemaPath, queryObject, schemaObject }) {
|
|
return {
|
|
query: queryPath,
|
|
schema: schemaPath,
|
|
child: function (property, { queryOverride, schemaOverride } = {}) {
|
|
return createInstance({
|
|
queryPath: queryPath.concat([ property ]),
|
|
schemaPath: schemaPath.concat([ property ]),
|
|
queryObject: queryOverride ?? queryObject[property],
|
|
schemaObject: schemaOverride ?? schemaObject[property]
|
|
});
|
|
}
|
|
};
|
|
}
|
|
|
|
module.exports = function createCursor({ query, schema }) {
|
|
return createInstance({
|
|
queryPath: [],
|
|
schemaPath: [],
|
|
queryObject: query,
|
|
schemaObject: schema
|
|
});
|
|
};
|