mirror of
https://github.com/JonasunderscoreJones/jonas_jones-api.git
synced 2025-10-24 01:29:19 +02:00
some progress
This commit is contained in:
parent
aea93a5527
commit
e3c15bd288
1388 changed files with 306946 additions and 68323 deletions
84
node_modules/mongoose/lib/schema/map.js
generated
vendored
Normal file
84
node_modules/mongoose/lib/schema/map.js
generated
vendored
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
'use strict';
|
||||
|
||||
/*!
|
||||
* ignore
|
||||
*/
|
||||
|
||||
const MongooseMap = require('../types/map');
|
||||
const SchemaMapOptions = require('../options/SchemaMapOptions');
|
||||
const SchemaType = require('../schematype');
|
||||
/*!
|
||||
* ignore
|
||||
*/
|
||||
|
||||
class Map extends SchemaType {
|
||||
constructor(key, options) {
|
||||
super(key, options, 'Map');
|
||||
this.$isSchemaMap = true;
|
||||
}
|
||||
|
||||
set(option, value) {
|
||||
return SchemaType.set(option, value);
|
||||
}
|
||||
|
||||
cast(val, doc, init) {
|
||||
if (val instanceof MongooseMap) {
|
||||
return val;
|
||||
}
|
||||
|
||||
const path = this.path;
|
||||
|
||||
if (init) {
|
||||
const map = new MongooseMap({}, path, doc, this.$__schemaType);
|
||||
|
||||
if (val instanceof global.Map) {
|
||||
for (const key of val.keys()) {
|
||||
let _val = val.get(key);
|
||||
if (_val == null) {
|
||||
_val = map.$__schemaType._castNullish(_val);
|
||||
} else {
|
||||
_val = map.$__schemaType.cast(_val, doc, true, null, { path: path + '.' + key });
|
||||
}
|
||||
map.$init(key, _val);
|
||||
}
|
||||
} else {
|
||||
for (const key of Object.keys(val)) {
|
||||
let _val = val[key];
|
||||
if (_val == null) {
|
||||
_val = map.$__schemaType._castNullish(_val);
|
||||
} else {
|
||||
_val = map.$__schemaType.cast(_val, doc, true, null, { path: path + '.' + key });
|
||||
}
|
||||
map.$init(key, _val);
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
return new MongooseMap(val, path, doc, this.$__schemaType);
|
||||
}
|
||||
|
||||
clone() {
|
||||
const schematype = super.clone();
|
||||
|
||||
if (this.$__schemaType != null) {
|
||||
schematype.$__schemaType = this.$__schemaType.clone();
|
||||
}
|
||||
return schematype;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This schema type's name, to defend against minifiers that mangle
|
||||
* function names.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
Map.schemaName = 'Map';
|
||||
|
||||
Map.prototype.OptionsConstructor = SchemaMapOptions;
|
||||
|
||||
Map.defaultOptions = {};
|
||||
|
||||
module.exports = Map;
|
||||
Loading…
Add table
Add a link
Reference in a new issue