-
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ObjectId
- Loading branch information
Showing
4 changed files
with
18 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 |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
## Examples | ||
|
||
```ts | ||
import { init, MongoClient } from "https://deno.land/x/[email protected].1/mod.ts"; | ||
import { init, MongoClient } from "https://deno.land/x/[email protected].2/mod.ts"; | ||
|
||
// Initialize the plugin | ||
await init(); | ||
|
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
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
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { assert } from "https://deno.land/[email protected]/testing/asserts.ts"; | ||
|
||
export enum CommandType { | ||
ConnectWithUri = "ConnectWithUri", | ||
ConnectWithOptions = "ConnectWithOptions", | ||
|
@@ -9,3 +11,12 @@ export enum CommandType { | |
Delete = "Delete", | ||
Update = "Update" | ||
} | ||
|
||
export interface ObjectId { | ||
$oid: string; | ||
} | ||
export function ObjectId($oid: string) { | ||
const isLegal = /[0-9a-fA-F]{24}/.test($oid); | ||
assert(isLegal, `ObjectId("${$oid}") is not legal.`); | ||
return { $oid }; | ||
} |