-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TODO: t.mjs script repros but not test
- Loading branch information
Showing
2 changed files
with
74 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#! /usr/bin/env node --unhandled-rejections=strict --enable-source-maps | ||
import util from 'node:util'; | ||
|
||
import { Code, MongoClient } from './lib/index.js'; | ||
|
||
util.inspect.defaultOptions.depth = 1000; | ||
const client = new MongoClient(process.env.MONGODB_URI); | ||
|
||
async function main() { | ||
await client.connect(); | ||
const collection = client.db('test_db').collection('test_collection'); | ||
await collection.insertMany([{}]); | ||
|
||
const updateOne = { | ||
filter: { $where: new Code('function () { sleep(1 * 100); return true; }') }, | ||
update: { $inc: { x: 1 } } | ||
}; | ||
const fnRes = await collection.bulkWrite([{ updateOne }], { maxTimeMS: 4 }).then( | ||
res => ({ res }), | ||
err => ({ err }) | ||
); | ||
console.log({ fnRes }); | ||
} | ||
|
||
main(process.argv) | ||
.then(console.log) | ||
.catch(console.error) | ||
.finally(() => client.close()); | ||
// node --unhandled-rejections=strict --enable-source-maps script.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters