I have the following simple shema:
var userSchema = new Schema({ name : String, age: Number, _creator: Schema.ObjectId }); var User = mongoose.model('User',userSchema);
What I want to do is create a new document and return to the client, but I want to exclude the "creator" field from one:
app.post('/example.json', function (req, res) { var user = new User({name: 'John', age: 45, _creator: 'some ObjectId'}); user.save(function (err) { if (err) throw err; res.json(200, {user: user});
At the end, I want to send the newly created user without the _creator field:
{ name: 'John', age: 45 }
Is it possible to make a request for a mongoose without too much searching?
PS : preferable to do it
javascript mongodb mongoose express
Erik Jun 22 2018-12-12T00: 00Z
source share