Details
-
Question
-
Status: Closed
-
Minor - P4
-
Resolution: Gone away
-
4.8.0
-
None
-
None
-
Not Needed
Description
Consider the following script:
const { MongoClient } = require('mongodb');
|
|
void async function main() {
|
const client = await MongoClient.connect('mongodb://localhost:27017/test');
|
|
const p1 = client.db().createCollection('User', {
|
timeseries: {
|
timeField: 'timestamp',
|
metaField: 'metadata',
|
granularity: 'hours',
|
}
|
});
|
|
await new Promise(resolve => setTimeout(resolve, 0));
|
|
const p2 = client.db().collection('User').insertMany([{ name: 'test' }]);
|
|
await Promise.all([p1, p2]);
|
console.log(await client.db().listCollections().toArray());
|
}();
|
Right now it errors out with:
/home/val/Workspace/MongoDB/mongoose/node_modules/mongodb/lib/cmap/connection.js:210
|
callback(new error_1.MongoServerError(document));
|
^
|
|
MongoServerError: Cannot create collection test.User - collection already exists.
|
at Connection.onMessage (/home/val/Workspace/MongoDB/mongoose/node_modules/mongodb/lib/cmap/connection.js:210:30)
|
I would intuitively expect this script to successfully create a timeseries collection since the `createCollection()` is sent off first. I realize this is probably a server issue rather than a Node driver issue, but I figured I'd ask here first in case I missed somewhere in the documentation that you're expected to call `createCollection()` before sending any operations if creating a timeseries collection.
Attachments
Issue Links
- depends on
-
NODE-4449 Investigate NODE-4448 - Sending `insertMany()` and `createCollection()` with timeseries concurrently results in collection without timeseries
-
- Closed
-