Guest User

Untitled

a guest
Nov 18th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. *Code to save Client and Scope:*
  2.  
  3. ```javascript
  4. let scope = new ScopeModel();
  5. scope.client = client._id;
  6. scope.markModified('client');
  7. console.log(scope);
  8. await scope.save();
  9. ```
  10.  
  11. *What's in the DB after save*
  12.  
  13. _id:5a0d80d892a84d0e4d144d45
  14. __v:0
  15.  
  16. *My Scope Schema Model:*
  17.  
  18. import mongoose from 'mongoose';
  19. let Schema = mongoose.Schema;
  20.  
  21. var ScopeSchema = Schema({
  22. client: [{ type: Schema.Types.ObjectId, ref: 'Client' }],
  23. service: [{ type: Schema.Types.ObjectId, ref: 'Service' }],
  24. grant: [{ type: Schema.Types.ObjectId, ref: 'Grant' }]
  25. });
  26.  
  27. export default ScopeSchema;
Add Comment
Please, Sign In to add comment