-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathindex.mjs
More file actions
38 lines (33 loc) · 1.22 KB
/
index.mjs
File metadata and controls
38 lines (33 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os from 'os';
import { readFileSync } from 'fs';
import { MongoClient, ObjectId } from 'mongodb';
async function main() {
const testCluster = 'mongodb+srv://...';
const client = new MongoClient(testCluster);
try {
await client.connect();
const buildInfo = await client.db('admin').command({ buildInfo: 1 });
const { version: driverVersion } = JSON.parse(
readFileSync(new URL('./node_modules/mongodb/package.json', import.meta.url), 'utf8')
);
console.log('Node.js version: ', process.version);
console.log('Driver version: ', driverVersion);
console.log('Server version: ', buildInfo.version);
console.log('OS: ', `${os.type()} ${os.release()} (${os.arch()})`);
console.log('---');
// Basic read smoke test (cluster user has read-only access)
const doc = await client
.db('sample_mflix')
.collection('movies')
.findOne({ _id: new ObjectId('573a1390f29313caabcd42e8') });
if (doc?.title !== 'The Great Train Robbery')
throw new Error(`Unexpected title: ${doc?.title}`);
console.log('Read smoke test: PASS');
} finally {
await client.close();
}
}
main().catch(err => {
console.error(err);
process.exit(1);
});