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

Function buildNestedPath

lib/schema.js:1036–1046  ·  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

1034 * @param {object} value the value to associate with the path in object
1035 */
1036 function buildNestedPath(path, object, value) {
1037 let i = 0, component = path[i];
1038 for (; i < path.length - 1; ++i, component = path[i]) {
1039 object[component] = object[component] == null ? {
1040 bsonType: 'object',
1041 properties: {}
1042 } : object[component];
1043 object = object[component].properties;
1044 }
1045 object[component] = value;
1046 }
1047
1048 const schemaMapPropertyReducer = (accum, [path, propertyConfig]) => {
1049 const bsonType = this.path(path).autoEncryptionType();

Callers 1

schemaMapPropertyReducerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected