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

Function buildNestedPath

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

1025 * @param {object} value the value to associate with the path in object
1026 */
1027 function buildNestedPath(path, object, value) {
1028 let i = 0, component = path[i];
1029 for (; i < path.length - 1; ++i, component = path[i]) {
1030 object[component] = object[component] == null ? {
1031 bsonType: 'object',
1032 properties: {}
1033 } : object[component];
1034 object = object[component].properties;
1035 }
1036 object[component] = value;
1037 }
1038
1039 const schemaMapPropertyReducer = (accum, [path, propertyConfig]) => {
1040 const bsonType = this.path(path).autoEncryptionType();

Callers 1

schemaMapPropertyReducerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected