Skip to content

Commit 33c6ef6

Browse files
committed
Added documentation
1 parent 2acddeb commit 33c6ef6

File tree

8 files changed

+106
-18
lines changed

8 files changed

+106
-18
lines changed

README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[![](https://dcbadge.vercel.app/api/server/fTpqUTMmVa?style=flat)](https://discord.gg/fTpqUTMmVa) [<img src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white" height="20px" />](https://www.linkedin.com/in/oskardudycz/) [![Github Sponsors](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&link=https://github.com/sponsors/oskardudycz/)](https://github.com/sponsors/oskardudycz/) [![blog](https://img.shields.io/badge/blog-event--driven.io-brightgreen)](https://event-driven.io/?utm_source=event_sourcing_nodejs) [![blog](https://img.shields.io/badge/%F0%9F%9A%80-Architecture%20Weekly-important)](https://www.architecture-weekly.com/?utm_source=event_sourcing_nodejs)
2+
3+
![](./src/docs/public/social.png)
4+
15
# Pongo
26

37
Pongo - MongoDB on Postgres with all strong consistency benefits
@@ -35,8 +39,8 @@ const cruella = { _id: uuid(), name: "Cruella", age: 40 };
3539
await pongoCollection.insertOne(roger);
3640
await pongoCollection.insertOne(cruella);
3741

38-
let inserted = await pongoCollection.insertOne(alice);
39-
const anitaId = inserted.insertedId;
42+
const { insertedId } = await pongoCollection.insertOne(alice);
43+
const anitaId = insertedId;
4044

4145
// Updating
4246
await users.updateOne({ _id: anitaId }, { $set: { age: 31 } });
@@ -74,8 +78,8 @@ const cruella = { _id: uuid(), name: "Cruella", age: 40 };
7478
await pongoCollection.insertOne(roger);
7579
await pongoCollection.insertOne(cruella);
7680

77-
let inserted = await pongoCollection.insertOne(alice);
78-
const anitaId = inserted.insertedId;
81+
const { insertedId } = await pongoCollection.insertOne(alice);
82+
const anitaId = insertedId;
7983

8084
// Updating
8185
await users.updateOne({ _id: anitaId }, { $set: { age: 31 } });

src/docs/.vitepress/config.mts

+1-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ export default defineConfig({
2323
sidebar: [
2424
{
2525
text: 'Documentation',
26-
items: [
27-
{ text: 'Getting Started', link: '/getting-started' },
28-
{ text: 'API Docs', link: '/api-docs' },
29-
],
26+
items: [{ text: 'Getting Started', link: '/getting-started' }],
3027
},
3128
],
3229

src/docs/getting-started.md

+91-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,94 @@
22

33
![](/logo.png)
44

5-
TODO
5+
Pongo is a MongoDB on Postgres with all strong consistency benefits.
6+
7+
Install Pongo as an npm module and save it to your package.json
8+
9+
```bash
10+
npm install @event-driven-io/pongo
11+
```
12+
13+
## Example
14+
15+
You can use Pongo syntax with explicit typing about supported syntax:
16+
17+
```ts
18+
import { pongoClient } from '@event-driven-io/pongo';
19+
import { v4 as uuid } from 'uuid';
20+
21+
type User = { name: string; age: number };
22+
23+
const connectionString =
24+
'postgresql://dbuser:[email protected]:3211/mydb';
25+
26+
const pongoClient = pongoClient(postgresConnectionString);
27+
const pongoDb = pongoClient.db();
28+
29+
const users = pongoDb.collection<User>('users');
30+
const roger = { name: 'Roger', age: 30 };
31+
const anita = { name: 'Anita', age: 25 };
32+
const cruella = { _id: uuid(), name: 'Cruella', age: 40 };
33+
34+
// Inserting
35+
await pongoCollection.insertOne(roger);
36+
await pongoCollection.insertOne(cruella);
37+
38+
let inserted = await pongoCollection.insertOne(alice);
39+
const anitaId = inserted.insertedId;
40+
41+
// Updating
42+
await users.updateOne({ _id: anitaId }, { $set: { age: 31 } });
43+
44+
// Deleting
45+
await pongoCollection.deleteOne({ _id: cruella._id });
46+
47+
// Finding by Id
48+
const anitaFromDb = await pongoCollection.findOne({ _id: anitaId });
49+
50+
// Finding more
51+
const users = await pongoCollection.find({ age: { $lt: 40 } });
52+
```
53+
54+
Or use MongoDB compliant shim:
55+
56+
```ts
57+
import { MongoClient } from '@event-driven-io/pongo';
58+
import { v4 as uuid } from 'uuid';
59+
60+
type User = { name: string; age: number };
61+
62+
const connectionString =
63+
'postgresql://dbuser:[email protected]:3211/mydb';
64+
65+
const pongoClient = new MongoClient(postgresConnectionString);
66+
const pongoDb = pongoClient.db();
67+
68+
const users = pongoDb.collection<User>('users');
69+
const roger = { name: 'Roger', age: 30 };
70+
const anita = { name: 'Anita', age: 25 };
71+
const cruella = { _id: uuid(), name: 'Cruella', age: 40 };
72+
73+
// Inserting
74+
await pongoCollection.insertOne(roger);
75+
await pongoCollection.insertOne(cruella);
76+
77+
let inserted = await pongoCollection.insertOne(alice);
78+
const anitaId = inserted.insertedId;
79+
80+
// Updating
81+
await users.updateOne({ _id: anitaId }, { $set: { age: 31 } });
82+
83+
// Deleting
84+
await pongoCollection.deleteOne({ _id: cruella._id });
85+
86+
// Finding by Id
87+
const anitaFromDb = await pongoCollection.findOne({ _id: anitaId });
88+
89+
// Finding more
90+
const users = await pongoCollection.find({ age: { $lt: 40 } }).toArray();
91+
```
92+
93+
## Is it production ready?
94+
95+
What's there it's safe to use, but it's far from being 100% compliant with MongoDB.

src/docs/index.md

+6-9
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,24 @@ layout: home
44

55
hero:
66
name: 'Pongo'
7-
text: 'Event Sourcing development made simple'
8-
tagline: Take your event-driven applications back to the future!
7+
text: 'Like Mongo<br/>But on Postgres<br/>And<br/>Strong Consistency'
8+
tagline: 'Flexibility or Consistency? Why not both!'
99
image:
1010
src: /logo.png
1111
alt: Pongo logo
1212
actions:
1313
- theme: brand
1414
text: Getting Started
1515
link: /getting-started
16-
- theme: alt
17-
text: API Docs
18-
link: /api-docs
1916
- theme: alt
2017
text: 🧑‍💻 Join Discord Server
2118
link: https://discord.gg/fTpqUTMmVa
2219

2320
features:
21+
- title: Keep your data consistent
22+
details: Don't be afraid of getting inconsistent state
2423
- title: DevExperience as prime goal
2524
details: Reduce the boilerplate, and focus on delivery with accessible tooling
26-
- title: Gain insights from your data
27-
details: Unleash the power of your data with Event Sourcing capabilities
28-
- title: All patterns in one place
29-
details: Use Decider, Workflow and other event-driven best practices seamlessly
25+
- title: Known experience, new capabilities
26+
details: Keep your muscle memory, but get new tricks and TypeScript superpowers
3027
---

src/docs/public/hexagon.png

-320 KB
Binary file not shown.

src/docs/public/logo-square.png

58.6 KB
Loading

src/docs/public/logo.png

46.6 KB
Loading

src/docs/public/social.png

-17 KB
Loading

0 commit comments

Comments
 (0)