UNPKG

jsm-core

Version:
89 lines (88 loc) 3.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._LocationSchemaFields = exports._AddressSchemaFields = exports._ItemUpdateSchemaFields = exports._ItemTagsSchemaFields = exports._UserSnapshotSchemaFields = exports._MediaSchemaFields = exports._FileAttributeSchemaFields = void 0; const mongoose_1 = require("mongoose"); /* -------------------------------------------------------------------------- */ /* COMMON */ /* -------------------------------------------------------------------------- */ exports._FileAttributeSchemaFields = { id: { type: String, default: null }, url: { type: String, default: null }, _id: false, // Disable _id for this subdocument }; exports._MediaSchemaFields = { id: { type: String, default: null }, url: { type: String, default: null }, type: { type: String, default: null }, size: { type: Number, default: null }, alt: { type: String, default: null }, order: { type: Number, default: null }, is_primary: { type: Boolean, default: false }, _id: false, }; /* -------------------------------------------------------------------------- */ /* SNAPSHOTS */ /* -------------------------------------------------------------------------- */ /* ---------------------------------- auth ---------------------------------- */ exports._UserSnapshotSchemaFields = { _id: { type: String, default: null }, tracking_id: { type: String, default: null }, first_name: { type: String, default: "" }, family_name: { type: String, default: "" }, phones: { type: [String], default: [] }, photo: { type: exports._FileAttributeSchemaFields, default: null, _id: false, // Disable _id for this subdocument }, role: { type: String, default: "" }, }; exports._ItemTagsSchemaFields = { type: mongoose_1.Schema.Types.Mixed, index: true, default: {}, _id: false, // Disable _id for this subdocument }; exports._ItemUpdateSchemaFields = new mongoose_1.Schema({ date: { type: Date, default: Date.now }, updated_by_system: { type: Boolean, default: false }, updated_by: { type: exports._UserSnapshotSchemaFields, default: null, }, action: { type: String }, updates: { type: [ { field: { type: String }, old_value: { type: mongoose_1.Schema.Types.Mixed }, new_value: { type: mongoose_1.Schema.Types.Mixed }, }, ], _id: false, default: [], }, }, { _id: false }); exports._AddressSchemaFields = { country_code: { type: String }, country_name: { type: String }, state_code: { type: String }, state_name: { type: String }, city_code: { type: String }, city_name: { type: String }, street_address: { type: String }, }; exports._LocationSchemaFields = { type: { type: String, // Don't do `{ location: { type: String } }` enum: ['Point'], // 'location.type' must be 'Point' required: false, // Optional, but if provided must be 'Point' default: 'Point' }, coordinates: { type: [Number], required: false, // Optional, but if provided must be an array of numbers default: [], _id: false, // Disable _id for this subdocument } };