Skip to content

Commit 8047c9b

Browse files
authored
ref: fix example
1 parent fbe269f commit 8047c9b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Diff for: README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,20 @@ $ npm install --save quickmongo
2323
# Example
2424

2525
```js
26-
const { Database } = require("quickmongo");
26+
import { Database } from 'quickmongo';
2727

28-
const db = new Database("mongodb://localhost/quickmongo");
28+
const db = new Database("mongodb://localhost:27017/quickmongo");
2929

3030
db.on("ready", () => {
3131
console.log("Connected to the database");
3232
doStuff();
3333
});
3434

35-
db.connect();
35+
// top-level awaits
36+
await db.connect();
37+
await doStuff();
3638

37-
function doStuff() {
39+
async function doStuff() {
3840
// Setting an object in the database:
3941
await db.set("userInfo", { difficulty: "Easy" });
4042
// -> { difficulty: 'Easy' }

0 commit comments

Comments
 (0)