@@ -12,18 +12,18 @@ npm install @event-driven-io/pongo
12
12
13
13
## Example
14
14
15
- You can use MongoDB compliant syntax:
15
+ You can use Pongo syntax with explicit typing about supported syntax:
16
16
17
17
``` ts
18
- import { MongoClient } from " @event-driven-io/pongo" ;
18
+ import { pongoClient } from " @event-driven-io/pongo" ;
19
19
import { v4 as uuid } from " uuid" ;
20
20
21
21
type User = { name: string ; age: number };
22
22
23
23
const connectionString =
24
24
" postgresql://dbuser:[email protected] :3211/mydb" ;
25
25
26
- const pongoClient = new MongoClient (postgresConnectionString );
26
+ const pongoClient = pongoClient (postgresConnectionString );
27
27
const pongoDb = pongoClient .db ();
28
28
29
29
const users = pongoDb .collection <User >(" users" );
@@ -48,21 +48,21 @@ await pongoCollection.deleteOne({ _id: cruella._id });
48
48
const anitaFromDb = await pongoCollection .findOne ({ _id: anitaId });
49
49
50
50
// Finding more
51
- const users = await pongoCollection .find ({ age: { $lt: 40 } }). toArray () ;
51
+ const users = await pongoCollection .find ({ age: { $lt: 40 } });
52
52
```
53
53
54
- Or a bit simpler Pongo syntax with explicit typing about supported syntax :
54
+ Or use MongoDB compliant shim :
55
55
56
56
``` ts
57
- import { pongoClient } from " @event-driven-io/pongo" ;
57
+ import { MongoClient } from " @event-driven-io/pongo" ;
58
58
import { v4 as uuid } from " uuid" ;
59
59
60
60
type User = { name: string ; age: number };
61
61
62
62
const connectionString =
63
63
" postgresql://dbuser:[email protected] :3211/mydb" ;
64
64
65
- const pongoClient = pongoClient (postgresConnectionString );
65
+ const pongoClient = new MongoClient (postgresConnectionString );
66
66
const pongoDb = pongoClient .db ();
67
67
68
68
const users = pongoDb .collection <User >(" users" );
@@ -87,7 +87,7 @@ await pongoCollection.deleteOne({ _id: cruella._id });
87
87
const anitaFromDb = await pongoCollection .findOne ({ _id: anitaId });
88
88
89
89
// Finding more
90
- const users = await pongoCollection .find ({ age: { $lt: 40 } });
90
+ const users = await pongoCollection .find ({ age: { $lt: 40 } }). toArray () ;
91
91
```
92
92
93
93
## Is it production ready?
0 commit comments