Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //billingCycle.js
  2.  
  3. const restful = require('node-restful')
  4. const mongoose = restful.mongoose
  5.  
  6. const creditSchema = new mongoose.Schema({
  7.     name: { type: String, required: true },
  8.     value: { type: Number, min: 0, required: true }
  9. })
  10.  
  11. const debtSchema = new mongoose.Schema({
  12.     name: { type: String, required: true },
  13.     value: { type: Number, min: 0, required: [true, 'Informe o valor do débito!'] },
  14.     status: { type: String, required: false, uppercase: true,
  15.         enum: ['PAGO', 'PENDENTE', 'AGENDADO'] }
  16. })
  17.  
  18. const billingCycleSchema = new mongoose.Schema({
  19.     name: { type: String, required: true },
  20.     month: { type: Number, min: 1, max: 12, required: true },
  21.     year: { type: Number, min:1970, max: 2100, required: true},
  22.     credits: [creditSchema],
  23.     debts: [debtSchema]
  24. })
  25.  
  26. module.exports = restful.model('BillingCycle', billingCycleSchema)
  27.  
  28. //billingCycleService.js
  29.  
  30. const BillingCycle = require('./billingCycle')
  31.  
  32. BillingCycle.methods(['get', 'post', 'put', 'delete'])
  33.  
  34. module.exports = BillingCycle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement