MCPcopy Create free account
hub / github.com/Automattic/mongoose / buildNestedPath

Function buildNestedPath

lib/schema.js:1047–1057  ·  view source on GitHub ↗

* `schemaMap`s are JSON schemas, which use the following structure to represent objects: * { field: { bsonType: 'object', properties: { ... } } } * * for example, a schema that looks like this `{ a: { b: int32 } }` would be encoded as * `{ a: { bsonType: 'object', properties: { b: < e

(path, object, value)

Source from the content-addressed store, hash-verified

1045 * @param {object} value the value to associate with the path in object
1046 */
1047 function buildNestedPath(path, object, value) {
1048 let i = 0, component = path[i];
1049 for (; i < path.length - 1; ++i, component = path[i]) {
1050 object[component] = object[component] == null ? {
1051 bsonType: 'object',
1052 properties: {}
1053 } : object[component];
1054 object = object[component].properties;
1055 }
1056 object[component] = value;
1057 }
1058
1059 const schemaMapPropertyReducer = (accum, [path, propertyConfig]) => {
1060 const bsonType = this.path(path).autoEncryptionType();

Callers 1

schemaMapPropertyReducerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected