Skip to content

Updated examples to use aggregation cursor and crud spec for 2.0 #2217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions primer/source/includes/examples-aggregation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,12 @@ operation:
db.collection('restaurants').aggregate(
[
{ $group: { "_id": "$borough", "count": { $sum: 1 } } }
],
function(err, result) {
assert.equal(err, null);
console.log(result);
callback(result);
}
);
]
).toArray(function(err, result) {
assert.equal(err, null);
console.log(result);
callback(result);
});
};
- pre: |
Call the ``aggregateRestaurants`` function.
Expand Down Expand Up @@ -158,8 +157,7 @@ operation:
[
{ $match: { "borough": "Queens", "cuisine": "Brazilian" } },
{ $group: { "_id": "$address.zipcode" , "count": { $sum: 1 } } }
],
function(err, result) {
]).toArray(function(err, result) {
assert.equal(err, null);
console.log(result);
callback(result);
Expand Down
2 changes: 1 addition & 1 deletion primer/source/includes/examples-insert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ operation:
language: javascript
code: |
var insertDocument = function(db, callback) {
db.collection('restaurants').insert( {
db.collection('restaurants').insertOne( {
"address" : {
"street" : "2 Avenue",
"zipcode" : "10075",
Expand Down
7 changes: 3 additions & 4 deletions primer/source/includes/examples-remove.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ operation:
language: javascript
code: |
var removeRestaurants = function(db, callback) {
db.collection('restaurants').remove(
db.collection('restaurants').deleteMany(
{ "borough": "Manhattan" },
function(err, results) {
console.log(results);
Expand Down Expand Up @@ -171,9 +171,8 @@ operation:
language: javascript
code: |
var removeRestaurants = function(db, callback) {
db.collection('restaurants').remove(
db.collection('restaurants').deleteOne(
{ "borough": "Queens" },
{ single: true },
function(err, results) {
console.log(results);
callback();
Expand Down Expand Up @@ -208,7 +207,7 @@ operation:
language: javascript
code: |
var removeRestaurants = function(db, callback) {
db.collection('restaurants').remove( {}, function(err, results) {
db.collection('restaurants').removeMany( {}, function(err, results) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Christian --
this example, it's not deleteMany? So, in node, we have deleteOne, deleteMany, and removeMany?

console.log(results);
callback();
});
Expand Down
7 changes: 3 additions & 4 deletions primer/source/includes/examples-update-fields.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ operation:
language: javascript
code: |
var updateRestaurants = function(db, callback) {
db.collection('restaurants').update(
db.collection('restaurants').updateOne(
{ "name" : "Juni" },
{
$set: { "cuisine": "American (New)" },
Expand Down Expand Up @@ -178,7 +178,7 @@ operation:
language: javascript
code: |
var updateRestaurants = function(db, callback) {
db.collection('restaurants').update(
db.collection('restaurants').updateOne(
{ "restaurant_id" : "41156888" },
{ $set: { "address.street": "East 31st Street" } },
function(err, results) {
Expand Down Expand Up @@ -214,13 +214,12 @@ operation:
language: javascript
code: |
var updateRestaurants = function(db, callback) {
db.collection('restaurants').update(
db.collection('restaurants').updateMany(
{ "address.zipcode": "10016" },
{
$set: { "borough": "Midtown" },
$currentDate: { "lastModified": true }
},
{ multi: true },
function(err, results) {
console.log(results);
callback();
Expand Down
2 changes: 1 addition & 1 deletion primer/source/includes/examples-update-replace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ operation:
language: javascript
code: |
var updateRestaurants = function(db, callback) {
db.collection('restaurants').update(
db.collection('restaurants').replaceOne(
{ "restaurant_id" : "41704620" },
{
"name" : "Vella 2",
Expand Down