Advertisement
xapu

Untitled

Apr 1st, 2018
655
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // TODO used also in account model export to common
  2. const paymentBluePrintSchema = new mongoose.Schema({
  3.   name: {
  4.     type: String
  5.   },
  6.   price: {
  7.     type: mongoose.SchemaTypes.Number,
  8.     required: true
  9.   },
  10.   payedBy: {
  11.     type: mongoose.SchemaTypes.ObjectId
  12.   }
  13. })
  14.  
  15. const staticTabSchema = new mongoose.Schema({
  16.   name: {
  17.     type: mongoose.SchemaTypes.String
  18.   },
  19.   status: {
  20.     type: mongoose.SchemaTypes.Boolean,
  21.     default: false
  22.   },
  23.   connectId: {
  24.     type: mongoose.SchemaTypes.ObjectId
  25.   }
  26. })
  27.  
  28. const userToOrganisationTransactionSchema = new mongoose.Schema({
  29.   payer: {
  30.     type: mongoose.Schema.Types.ObjectId
  31.   },
  32.   reciever: {
  33.     type: mongoose.Schema.Types.ObjectId
  34.   },
  35.   limit: {
  36.     type: mongoose.SchemaTypes.Number,
  37.     default: 0
  38.   },
  39.   total: {
  40.     type: mongoose.SchemaTypes.Number,
  41.     default: 0
  42.   },
  43.   dateStamp: {
  44.     type: mongoose.SchemaTypes.Date,
  45.     default: Date.now
  46.   },
  47.   itemsOnTab: {
  48.     type: [paymentBluePrintSchema],
  49.     default: []
  50.   },
  51.   connectId: {
  52.     type: mongoose.SchemaTypes.ObjectId
  53.   },
  54.   isOpen: {
  55.     type: mongoose.Schema.Types.Boolean,
  56.     default: true
  57.   }
  58. })
  59.  
  60. const pendingInvitation = new mongoose.Schema({
  61.   key: {
  62.     type: mongoose.SchemaTypes.ObjectId,
  63.     default: mongoose.Types.ObjectId(),
  64.     required: true
  65.   },
  66.   organisationId: {
  67.     type: mongoose.SchemaTypes.ObjectId,
  68.     required: true
  69.   }
  70. })
  71.  
  72. const organisationSchema = new mongoose.Schema({
  73.   owner: {
  74.     type: mongoose.SchemaTypes.ObjectId,
  75.     required: true,
  76.     ref: 'User'
  77.   },
  78.   name: {
  79.     type: mongoose.SchemaTypes.String,
  80.     required: true
  81.   },
  82.   balance: {
  83.     type: mongoose.SchemaTypes.Number,
  84.     required: true,
  85.     default: 0
  86.   },
  87.   workers: {
  88.     type: [{ type: mongoose.SchemaTypes.ObjectId, ref: 'User' }],
  89.     default: []
  90.   },
  91.   pendingInvitations: {
  92.     type: [pendingInvitation],
  93.     default: []
  94.   },
  95.   staticAccounts: {
  96.     type: [staticTabSchema],
  97.     default: []
  98.   },
  99.   income: {
  100.     type: [userToOrganisationTransactionSchema],
  101.     default: []
  102.   },
  103.   expenditure: {
  104.     type: [userToOrganisationTransactionSchema],
  105.     default: []
  106.   },
  107.   soldItemsBlueprint: {
  108.     type: [paymentBluePrintSchema],
  109.     default: []
  110.   },
  111.   tabs: {
  112.     type: mongoose.SchemaTypes.Array,
  113.     default: []
  114.   }
  115. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement