Skip to content

Commit

Permalink
add example doc
Browse files Browse the repository at this point in the history
  • Loading branch information
manyuanrong committed Mar 4, 2020
1 parent de602a4 commit 6a5fefd
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,26 @@
## Examples

```ts
// TODO
import { init, MongoClient } from "https://deno.land/x/mongo/mod.ts";

// Initialize the plugin and specify the binary release version (because the binary currently has no idea how to associate the version in ts and the binary)
await init("0.1.0");

const client = new MongoClient();
client.connectWithUri("mongodb://localhost:27017");

const db = getClient().database("test");
const users = db.collection("users");

// insert
const insertId = await users.insertOne({
username: "user1",
password: "pass1"
});

// findOne
const user1 = await users.findOne({ _id: insertId });

// deleteOne
const deleteCount = await users.deleteOne({ _id: insertId });
```

0 comments on commit 6a5fefd

Please sign in to comment.