Skip to content

Commit 7816639

Browse files
committed
Create example
1 parent 5ba63b6 commit 7816639

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

examples/create.rb

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Insert a document
2+
require 'date'
3+
4+
result = client[:restaurants].insert_one({
5+
address: {
6+
street: '2 Avenue',
7+
zipcode: 10075,
8+
building: 1480,
9+
coord: [-73.9557413, 40.7720266]
10+
},
11+
borough: 'Manhattan',
12+
cuisine: 'Italian',
13+
grades: [
14+
{
15+
date: DateTime.strptime('2014-10-01', '%Y-%m-%d'),
16+
grade: 'A',
17+
score: 11
18+
},
19+
{
20+
date: DateTime.strptime('2014-01-16', '%Y-%m-%d'),
21+
grade: 'B',
22+
score: 17
23+
}
24+
],
25+
name: 'Vella',
26+
restaurant_id: '41704620'
27+
})
28+
29+
result.n #=> returns 1, because 1 document was inserted.
30+

0 commit comments

Comments
 (0)