summaryrefslogtreecommitdiffstats
path: root/node_modules/mongoose/lib/schema/map.js
diff options
context:
space:
mode:
authorGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
committerGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
commite06ec920f7a5d784e674c4c4b4e6d1da3dc7391d (patch)
tree55713f725f77b44ebfec86e4eec3ce33e71458ca /node_modules/mongoose/lib/schema/map.js
downloadwebsite_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.gz
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.bz2
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.zip
api, login, auth
Diffstat (limited to 'node_modules/mongoose/lib/schema/map.js')
-rw-r--r--node_modules/mongoose/lib/schema/map.js62
1 files changed, 62 insertions, 0 deletions
diff --git a/node_modules/mongoose/lib/schema/map.js b/node_modules/mongoose/lib/schema/map.js
new file mode 100644
index 0000000..468faea
--- /dev/null
+++ b/node_modules/mongoose/lib/schema/map.js
@@ -0,0 +1,62 @@
+'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;
+ }
+
+ if (init) {
+ const map = new MongooseMap({}, this.path, doc, this.$__schemaType);
+
+ if (val instanceof global.Map) {
+ for (const key of val.keys()) {
+ map.$init(key, map.$__schemaType.cast(val.get(key), doc, true));
+ }
+ } else {
+ for (const key of Object.keys(val)) {
+ map.$init(key, map.$__schemaType.cast(val[key], doc, true));
+ }
+ }
+
+ return map;
+ }
+
+ return new MongooseMap(val, this.path, doc, this.$__schemaType);
+ }
+
+ clone() {
+ const schematype = super.clone();
+
+ if (this.$__schemaType != null) {
+ schematype.$__schemaType = this.$__schemaType.clone();
+ }
+ return schematype;
+ }
+}
+
+Map.prototype.OptionsConstructor = SchemaMapOptions;
+
+Map.defaultOptions = {};
+
+module.exports = Map;