Skip to content

Instantly share code, notes, and snippets.

@drinchev
Created December 29, 2018 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drinchev/9957a01d1db60c3cf4cdeb8a17e20fd1 to your computer and use it in GitHub Desktop.
Save drinchev/9957a01d1db60c3cf4cdeb8a17e20fd1 to your computer and use it in GitHub Desktop.
stack-overflow/53972854
const mongoose = require( "mongoose" );
mongoose.connect( "mongodb://localhost:27017/test", { useNewUrlParser : true } );
const Item = mongoose.model( "Item", {
inv : {
type : Object,
default : {}
}
} );
const item = new Item( { inv : { foo : "bar" } } );
item.save().then( item => {
console.log( item );
delete item.inv.foo;
item.save().then( item => {
console.log( item );
} );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment