Skip to content

Commit

Permalink
Updated samples to use Pongo 0.16.1
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardudycz committed Oct 9, 2024
1 parent a0a5257 commit 7f871fd
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
16 changes: 8 additions & 8 deletions samples/simple-ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion samples/simple-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@
"dist"
],
"dependencies": {
"@event-driven-io/pongo": "0.15.0"
"@event-driven-io/pongo": "0.16.1"
}
}
10 changes: 5 additions & 5 deletions samples/simple-ts/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { pongoClient } from '@event-driven-io/pongo';
import { v7 as uuid } from 'uuid';
import { prettyJson } from '@event-driven-io/dumbo';
import { ObjectId, pongoClient } from '@event-driven-io/pongo';

type User = { _id?: string; name: string; age: number };

Expand All @@ -13,7 +13,7 @@ const pongoDb = pongo.db();
const users = pongoDb.collection<User>('users');
const roger = { name: 'Roger', age: 30 };
const anita = { name: 'Anita', age: 25 };
const cruella = { _id: uuid(), name: 'Cruella', age: 40 };
const cruella = { _id: ObjectId(), name: 'Cruella', age: 40 };

// Inserting
await users.insertOne(roger);
Expand All @@ -30,10 +30,10 @@ await users.deleteOne({ _id: cruella._id });

// Finding by Id
const anitaFromDb = await users.findOne({ _id: anitaId });
console.log(JSON.stringify(anitaFromDb));
console.log(prettyJson(anitaFromDb));

// Finding more
const usersFromDB = await users.find({ age: { $lt: 40 } });
console.log(JSON.stringify(usersFromDB));
console.log(prettyJson(usersFromDB));

await pongo.close();
5 changes: 3 additions & 2 deletions samples/simple-ts/src/shim.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { prettyJson } from '@event-driven-io/dumbo';
import { MongoClient } from '@event-driven-io/pongo/shim';

type User = { name: string; age: number };
Expand Down Expand Up @@ -29,10 +30,10 @@ await users.updateOne({ _id: anitaId }, { $set: { age: 31 } });

// Finding by Id
const anitaFromDb = await users.findOne({ _id: anitaId });
console.log(anitaFromDb);
console.log(prettyJson(anitaFromDb));

// Finding more
const usersFromDB = await users.find({ age: { $lt: 40 } }).toArray();
console.log(usersFromDB);
console.log(prettyJson(usersFromDB));

await pongoClient.close();
10 changes: 5 additions & 5 deletions samples/simple-ts/src/typedClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { pongoClient } from '@event-driven-io/pongo';
import { v7 as uuid } from 'uuid';
import { prettyJson } from '@event-driven-io/dumbo';
import { ObjectId, pongoClient } from '@event-driven-io/pongo';
import config from './pongo.config';

const connectionString =
Expand All @@ -14,7 +14,7 @@ const pongoDb = pongo.database;
const users = pongoDb.users;
const roger = { name: 'Roger', age: 30 };
const anita = { name: 'Anita', age: 25 };
const cruella = { _id: uuid(), name: 'Cruella', age: 40 };
const cruella = { _id: ObjectId(), name: 'Cruella', age: 40 };

// Inserting
await users.insertOne(roger);
Expand All @@ -31,10 +31,10 @@ await users.deleteOne({ _id: cruella._id });

// Finding by Id
const anitaFromDb = await users.findOne({ _id: anitaId });
console.log(anitaFromDb);
console.log(prettyJson(anitaFromDb));

// Finding more
const usersFromDB = await users.find({ age: { $lt: 40 } });
console.log(usersFromDB);
console.log(prettyJson(usersFromDB));

await pongo.close();

0 comments on commit 7f871fd

Please sign in to comment.