Skip to content

Commit

Permalink
chore(docs): update docs (denodrivers#292)
Browse files Browse the repository at this point in the history
* chore(docs): update docs

* apply deno fmt
  • Loading branch information
erfanium authored Nov 12, 2021
1 parent 727e29a commit 304a941
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ await client.connect(
```ts
// Defining schema interface
interface UserSchema {
_id: { $oid: string };
_id: Bson.ObjectId;
username: string;
password: string;
}
Expand Down Expand Up @@ -120,7 +120,7 @@ const estimatedCount = await users.estimatedDocumentCount({
const docs = await users.aggregate([
{ $match: { username: "many" } },
{ $group: { _id: "$username", total: { $sum: 1 } } },
]);
]).toArray();
```

### Update
Expand All @@ -137,6 +137,18 @@ const { matchedCount, modifiedCount, upsertedId } = await users.updateMany(
);
```

### Replace

```ts
const { matchedCount, modifiedCount, upsertedId } = await users.replaceOne(
{ username: "a" },
{
username: "user1",
password: "pass1",
}, // new document
);
```

### Delete

```ts
Expand All @@ -153,13 +165,13 @@ const cursor = users.find();
// Skip & Limit
cursor.skip(10).limit(10);

// toArray
const users = await cursor.toArray();

// iterate
// iterate results
for await (const user of cursor) {
console.log(user);
}

// or save results to array (uses more memory)
const users = await cursor.toArray();
```

### GridFS
Expand Down

0 comments on commit 304a941

Please sign in to comment.