Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // src/models/asset.js
- 'use strict'
- import _ from '../../lodash-mixins'
- module.exports = Mongoose => {
- const Schema = Mongoose.Schema
- const modelSchema = new Schema({
- status: {
- type: Schema.Types.String,
- default: 'unlocked',
- select: true,
- minlength: 6, // Length of 'locked'
- maxlength: 108, // Length of _.passwordHash value
- validate: status => _.indexOf( ['unlocked','locked'], status) !== -1 || status.length === 108
- },
- _createdBy: [{
- type: Schema.Types.ObjectId,
- ref: 'Account'
- }],
- _modifiedBy: [{
- type: Schema.Types.ObjectId,
- ref: 'Account'
- }],
- _groups: [{
- type: Schema.Types.ObjectId,
- ref: 'Group'
- }],
- attributes: [{
- _field: {
- type: Schema.Types.ObjectId,
- ref: 'Field'
- },
- value: {
- type: Schema.Types.Mixed,
- required: true
- }
- }],
- _partition: {
- type: Schema.Types.ObjectId,
- ref: 'Partition'
- }
- }, {
- timestamps: {
- createdAt: 'created_at',
- updatedAt: 'updated_at'
- }
- })
- return Mongoose.model( 'Asset', modelSchema )
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement