How to use the mongoose.SchemaTypes.ObjectId function in mongoose

To help you get started, we’ve selected a few mongoose examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github usehenri / henri / packages / mongoose / types.js View on Github external
const types = require('mongoose').SchemaTypes;

module.exports = {
  // Mongoose specific
  String: types.String,
  Number: types.Number,
  Boolean: types.Boolean,
  DocumentArray: types.DocumentArray,
  Embedded: types.Embedded,
  Array: types.Array,
  Buffer: types.Buffer,
  Date: types.Date,
  ObjectId: types.ObjectId,
  Mixed: types.Mixed,
  Decimal128: types.Decimal128,
  Object: types.Mixed,
  Bool: types.Boolean,

  // Sequelize specific
  STRING: types.String,
  CHAR: types.String,
  TEXT: types.String,
  TINYINT: types.Number,
  SMALLINT: types.Number,
  MEDIUMINT: types.Number,
  INTEGER: types.Number,
  BIGINT: types.Number,
  NUMBER: types.Number,
  FLOAT: types.Number,
github vellengs / nestx / packages / servers / nestx-base / src / schemas / group.schema.ts View on Github external
import { Schema, SchemaTypes as t } from "mongoose";
import { utils } from "nestx-common";
const { transform } = utils;

export const GroupSchema = new Schema(
  {
    outid: { type: t.Number },
    name: { type: t.String },
    icon: { type: t.String },
    isRegion: { type: t.Boolean },
    order: { type: t.Number },
    parent: { type: t.ObjectId, ref: "Group" },
    paths: [{ type: t.ObjectId, ref: "Group" }],
    director: { type: t.ObjectId, ref: "User" },
    description: { type: t.String }
  },
  { timestamps: true }
);

GroupSchema.set("toJSON", {
  transform
});
github vellengs / nestx / packages / servers / nestx-base / src / schemas / group.schema.ts View on Github external
import { Schema, SchemaTypes as t } from "mongoose";
import { utils } from "nestx-common";
const { transform } = utils;

export const GroupSchema = new Schema(
  {
    outid: { type: t.Number },
    name: { type: t.String },
    icon: { type: t.String },
    isRegion: { type: t.Boolean },
    order: { type: t.Number },
    parent: { type: t.ObjectId, ref: "Group" },
    paths: [{ type: t.ObjectId, ref: "Group" }],
    director: { type: t.ObjectId, ref: "User" },
    description: { type: t.String }
  },
  { timestamps: true }
);

GroupSchema.set("toJSON", {
  transform
});
github vellengs / typerx / packages / server / src / modules / cms / schemas / comment.schema.ts View on Github external
import { Schema, SchemaTypes as t, SchemaOptions, model } from 'mongoose';

export const schema = new Schema({
    name: t.String,
    article: { ref: 'Article', type: t.ObjectId },
    text: t.String,
    
},
    { timestamps: true });
github vellengs / nestx / packages / servers / nestx-base / src / schemas / user.schema.ts View on Github external
type: t.String,
    mobile: { type: t.String, unique: true, required: true },
    roles: [
      {
        type: t.ObjectId,
        ref: 'Role',
      },
    ],
    groups: [
      {
        type: t.ObjectId,
        ref: 'Group',
      },
    ],
    profile: {
      type: t.ObjectId,
      ref: 'Profile',
    },
    isDisable: {
      type: t.Boolean,
    },
    isAdmin: {
      type: t.Boolean,
    },
    isApproved: {
      type: t.Boolean,
    },
    expired: {
      type: t.Date,
    },
  },
  {
github vellengs / nestx-server / packages / base / src / schemas / role.schema.ts View on Github external
import { Schema, SchemaTypes as t, SchemaOptions } from "mongoose";
import { utils } from "nestx-common";
const { transform } = utils;

const option: SchemaOptions = {};
option.timestamps = true;

export const RoleSchema = new Schema(
  {
    name: { type: t.String },
    description: { type: t.String },
    permissions: [{ type: t.ObjectId, ref: "Menu" }]
  },
  option
);

RoleSchema.set("toJSON", {
  transform
});
github vellengs / nestx / packages / server / src / cms / schemas / page.schema.ts View on Github external
const option: SchemaOptions = {};
option.timestamps = true;

export const PageSchema = new Schema(
  {
    name: { type: t.String },
    title: t.String,
    keyword: t.String,
    description: t.String,
    sort: t.Number,
    disable: t.Boolean,
    publish: { type: t.Date, default: Date.now },
    meta: {
      ref: 'Meta',
      type: t.ObjectId,
    },
    content: {
      ref: 'Content',
      type: t.ObjectId,
    },
    template: {
      ref: 'Content',
      type: t.ObjectId,
    },
  },
  option,
);
PageSchema.set('toJSON', {
  transform,
});
github vellengs / nestx / packages / server / src / core / schemas / group.schema.ts View on Github external
import { Schema, SchemaTypes as t } from 'mongoose';
import { transform } from './../../utils';

export const GroupSchema = new Schema(
  {
    outid: { type: t.Number },
    name: { type: t.String },
    icon: { type: t.String },
    isRegion: { type: t.Boolean },
    order: { type: t.Number },
    parent: { type: t.ObjectId, ref: 'Group' },
    paths: [{ type: t.ObjectId, ref: 'Group' }],
    director: { type: t.ObjectId, ref: 'User' },
    description: { type: t.String },
  },
  { timestamps: true },
);

GroupSchema.set('toJSON', {
  transform,
});
github vellengs / nestx / packages / server / src / core / schemas / menu.schema.ts View on Github external
enable: { type: t.Boolean },
    expanded: { type: t.Boolean },
    acl: { type: t.String },
    paths: [
      {
        type: t.ObjectId,
        ref: 'Menu',
      },
    ],
    parent: {
      type: t.ObjectId,
      ref: 'Menu',
    },
    permissions: [
      {
        type: t.ObjectId,
        ref: 'Menu',
      },
    ],
    isMenu: {
      type: t.Boolean,
      default: true,
    },
  },
  option,
);

MenuSchema.set('toJSON', {
  transform,
});
github vellengs / nestx-server / src / core / schemas / menu.schema.ts View on Github external
icon: { type: t.String },
    order: { type: t.Number, default: 100 },
    enable: { type: t.Boolean },
    expanded: { type: t.Boolean },
    acl: { type: t.String },
    paths: [{
        type: t.ObjectId,
        ref: 'Menu'
    }],
    parent: {
        type: t.ObjectId,
        ref: 'Menu'
    },
    permissions: [
        {
            type: t.ObjectId,
            ref: 'Menu'
        }
    ],
    isMenu: {
        type: t.Boolean,
        default: true
    }
}, option);