Advertisement
Guest User

Untitled

a guest
Jan 26th, 2016
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // src/models/asset.js
  2. 'use strict'
  3.  
  4. import _ from '../../lodash-mixins'
  5.  
  6. module.exports = Mongoose => {
  7.     const Schema = Mongoose.Schema
  8.  
  9.     const modelSchema = new Schema({
  10.         status: {
  11.             type: Schema.Types.String,
  12.             default: 'unlocked',
  13.             select: true,
  14.             minlength: 6,   // Length of 'locked'
  15.             maxlength: 108, // Length of _.passwordHash value
  16.             validate: status => _.indexOf( ['unlocked','locked'], status) !== -1 || status.length === 108
  17.         },
  18.         _createdBy: [{
  19.             type: Schema.Types.ObjectId,
  20.             ref: 'Account'
  21.         }],
  22.         _modifiedBy: [{
  23.             type: Schema.Types.ObjectId,
  24.             ref: 'Account'
  25.         }],
  26.         _groups: [{
  27.             type: Schema.Types.ObjectId,
  28.             ref: 'Group'
  29.         }],
  30.         attributes: [{
  31.             _field: {
  32.                 type: Schema.Types.ObjectId,
  33.                 ref: 'Field'
  34.             },
  35.             value: {
  36.                 type: Schema.Types.Mixed,
  37.                 required: true
  38.             }
  39.         }],
  40.         _partition: {
  41.             type: Schema.Types.ObjectId,
  42.             ref: 'Partition'
  43.         }
  44.     }, {
  45.         timestamps: {
  46.             createdAt: 'created_at',
  47.             updatedAt: 'updated_at'
  48.         }
  49.     })
  50.  
  51.     return Mongoose.model( 'Asset', modelSchema )
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement