[DOCS-8597] Node driver example throws "writeConcern requires callback" error Created: 15/Aug/16  Updated: 17/Aug/20  Resolved: 17/Aug/20

Status: Closed
Project: Documentation
Component/s: drivers
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Mark Helmstetter Assignee: Matt Broadstone
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

https://mongodb.github.io/node-mongodb-native/api-articles/nodekoarticle1.html#mongo-db-and-collections


Participants:
Days since reply: 3 years, 25 weeks, 2 days ago
Story Points: 0.3

 Description   

The example on the A Basic introduction to Mongo DB page does not execute as-is.

If I copy/paste that example and run it, I get the following error:

Error: writeConcern requires callback



 Comments   
Comment by Christopher Cho [ 17/Aug/20 ]

The example is on the linked page, but it seems like the creator has resolved some version mismatch. Closing the issue.

Comment by Matt Broadstone [ 17/Aug/20 ]

chris.cho I don't think this documentation exists anymore on the new docs site, fine to close it unless you can find the snippet in question there.

Comment by Christopher Cho [ 14/Aug/20 ]

matt.broadstone

Dug up this old issue. Is this an update that you'd like to handle or close?

Comment by Mark Helmstetter [ 19/Oct/17 ]

Sorry, I didn't note the driver version at the time and I'm not able to reproduce now. Perhaps I had some mismatch of versions or some other environment issue.

This was the example in the 1.4.9 docs, "A Basic introduction to Mongo DB", 2nd example on the page under the heading "Mongo DB and Collections", url: https://mongodb.github.io/node-mongodb-native/api-articles/nodekoarticle1.html#mongo-db-and-collections. Here's the example:

// Retrieve
var MongoClient = require('mongodb').MongoClient;
 
// Connect to the db
MongoClient.connect("mongodb://localhost:27017/exampleDb", function(err, db) {
  if(err) { return console.dir(err); }
 
  db.collection('test', function(err, collection) {});
 
  db.collection('test', {w:1}, function(err, collection) {});
 
  db.createCollection('test', function(err, collection) {});
 
  db.createCollection('test', {w:1}, function(err, collection) {});
 
});

Generated at Thu Feb 08 07:56:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.