Skip to content

Instantly share code, notes, and snippets.

{
"_id" : ObjectId("5063114bd386d8fadbd6b004"),
"name" : "Brian D. Goodman",
"organizations" : ["MongoDB"],
"locations" : [
{ "type" : "work",
"address" : "229 W 34 St., 5th floor",
"city" : "New York",
"state" : "NY",
"zipcode" : "10036"
{
"_id" : ObjectId("5063114bd386d8fadbd6b004"),
"name" : "Brian D. Goodman",
"organizations" : ["MongoDB"],
"locations" : [
{ "type" : "work",
"address" : "229 W 34 St., 5th floor",
"city" : "New York",
"state" : "NY",
"zipcode" : "10036"
class Product {
String productName;
List<Features> ff;
Date introDate;
List<Date> versDates;
int[] unitBundles;
//…
}
<product>
<name>widget1</name>
<features>
<feature>
<text>good texture</text>
<type>A</type>
</feature>
</features>
<introDate>20140204</introDate>
<versDates>
<p name=“widget1” ftxt1=“good texture” ftyp1=“A” idt=“20140203” …
<p name=“widget2” ftxt1=“not fragile” ftyp1=“A” idt=“20110117” …
<p name=“widget3” ftxt1=“dense” idt=“20140203” …
<p name=“widget4” idt=“20140203” versD=“20130403,20130104,20100605” …
{
result: { ok: 1, n: 1 },
connection: … Connection executed against …,
ops: [... Array of documents inserted ...]
}
```
#### Update 2.0 return value
```
{
{
result: { ok: 1, n: 1 },
connection: … Connection executed against …,
}
mkdir myprojects
cd myprojects
npm init
npm install mongodb --save
var breakfastSchema = new mongoose.Schema({
steak: {
type: String,
required: true,
enum: ['flank', 'ribeye']
},
eggs: {
type: Number,
required: true,
min: 2
var updates = { $unset: { steak: true }, $set: { eggs: 0 } };
Breakfast.update({}, updates, callback);