Professor
Professor

Reputation: 2154

mongoDB 3.4.7 error The field 'w' is not a valid collection option

i am trying to create a new collection in mongodb giving write acknowledgment permission

i tried doing it this way

db.createCollection(databaseName, { w: 1 });

but it gives me errors saying

MongoError: The field 'w' is not a valid collection option. Options: { w: 1 }
at Function.MongoError.create (C:\monex\example\main\node_modules\mongodb-core\lib\error.js:31:11)
at C:\monex\example\main\node_modules\mongodb-core\lib\topologies\server.js:778:66
at Callbacks.emit (C:\monex\example\main\node_modules\mongodb-core\lib\topologies\server.js:95:3)
at .messageHandler (C:\monex\example\main\node_modules\mongodb-core\lib\topologies\server.js:249:23)
at Socket.<anonymous> (C:\monex\example\main\node_modules\mongodb-core\lib\connection\connection.js:265:22)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:172:18)
at Socket.Readable.push (_stream_readable.js:130:10)
at TCP.onread (net.js:535:20)

Upvotes: 0

Views: 150

Answers (1)

Ravi Teja
Ravi Teja

Reputation: 659

db.createCollection("log", { capped : true, size : 5242880, max : 5000 } )

try this and it creates collection

db.createCollection("log1", { w: 1} );

This also creates the collection

and also check the MongoDB version

Upvotes: 1

Related Questions