Skip to content

Instantly share code, notes, and snippets.

@dclarke-modus
Last active November 16, 2017 12:25
Show Gist options
  • Save dclarke-modus/08e8f323ba8180f1953783a743830578 to your computer and use it in GitHub Desktop.
Save dclarke-modus/08e8f323ba8180f1953783a743830578 to your computer and use it in GitHub Desktop.
*Code to save Client and Scope:*
```javascript
let scope = new ScopeModel();
scope.client = client._id;
scope.markModified('client');
console.log(scope);
await scope.save();
```
*What's in the DB after save*
_id:5a0d80d892a84d0e4d144d45
__v:0
*My Scope Schema Model:*
import mongoose from 'mongoose';
let Schema = mongoose.Schema;
var ScopeSchema = Schema({
client: [{ type: Schema.Types.ObjectId, ref: 'Client' }],
service: [{ type: Schema.Types.ObjectId, ref: 'Service' }],
grant: [{ type: Schema.Types.ObjectId, ref: 'Grant' }]
});
export default ScopeSchema;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment