NovaKevin

organization.js

May 11th, 2018
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Schema = require('mongoose').Schema;
  2. // Each contact type has it's own schema
  3. const CallSchema = require('./call');
  4. const TextSchema = require('./text');
  5. const ChatSchema = require('./chat');
  6.  
  7. var OrganizationSchema = new Schema(
  8.     {
  9.         name: {
  10.             type: String,
  11.             required: true
  12.         },
  13.         website: {
  14.             type: String,
  15.             required: true
  16.         },
  17.         // "contacts" container is required
  18.         // along with at least one of the contact-type properties
  19.         contacts: {
  20.             call: { // call OR
  21.                 type: [CallSchema]
  22.             },
  23.             text: { // text OR
  24.                 type: [TextSchema]
  25.             },
  26.             chat: { // chat
  27.                 type: [ChatSchema]
  28.             }
  29.         }
  30.     }
  31. );
  32.  
  33. module.exports = OrganizationSchema;
Advertisement
Add Comment
Please, Sign In to add comment