Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Used UUID v7 as sequential random id generator #94

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ You can use Pongo syntax with explicit typing about supported syntax:

```ts
import { pongoClient } from "@event-driven-io/pongo";
import { v4 as uuid } from "uuid";
import { v7 as uuid } from "uuid";

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

Expand Down Expand Up @@ -61,7 +61,7 @@ Or use MongoDB compliant shim:

```ts
import { MongoClient } from "@event-driven-io/pongo/shim";
import { v4 as uuid } from "uuid";
import { v7 as uuid } from "uuid";

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

Expand Down
2 changes: 1 addition & 1 deletion 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 { v4 as uuid } from 'uuid';
import { v7 as uuid } from 'uuid';

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

Expand Down
2 changes: 1 addition & 1 deletion 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 { v4 as uuid } from 'uuid';
import { v7 as uuid } from 'uuid';
import config from './pongo.config';

const connectionString =
Expand Down
4 changes: 2 additions & 2 deletions src/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You can use Pongo syntax with explicit typing about supported syntax:

```ts
import { pongoClient } from '@event-driven-io/pongo';
import { v4 as uuid } from 'uuid';
import { v7 as uuid } from 'uuid';

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

Expand Down Expand Up @@ -59,7 +59,7 @@ Or use MongoDB compliant shim:

```ts
import { MongoClient } from '@event-driven-io/pongo/shim';
import { v4 as uuid } from 'uuid';
import { v7 as uuid } from 'uuid';

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

Expand Down
10 changes: 5 additions & 5 deletions src/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 src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@event-driven-io/pongo-core",
"version": "0.16.0-alpha.11",
"version": "0.16.0",
"description": "Pongo - Mongo with strong consistency on top of Postgres",
"type": "module",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion src/packages/dumbo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@event-driven-io/dumbo",
"version": "0.12.0-alpha.11",
"version": "0.12.0",
"description": "Dumbo - tools for dealing with PostgreSQL",
"type": "module",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/packages/pongo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@event-driven-io/pongo",
"version": "0.16.0-alpha.11",
"version": "0.16.0",
"description": "Pongo - Mongo with strong consistency on top of Postgres",
"type": "module",
"scripts": {
Expand Down Expand Up @@ -87,7 +87,7 @@
"pongo": "./dist/cli.js"
},
"peerDependencies": {
"@event-driven-io/dumbo": "0.12.0-alpha.11",
"@event-driven-io/dumbo": "0.12.0",
"@types/mongodb": "^4.0.7",
"@types/pg": "^8.11.6",
"@types/uuid": "^10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/packages/pongo/src/commandLine/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const startRepl = async (options: {
setLogLevel(process.env.DUMBO_LOG_LEVEL ?? options.logging.logLevel);
setLogStyle(process.env.DUMBO_LOG_STYLE ?? options.logging.logStyle);

console.log(chalk.green('Starting Pongo Shell (version: 0.16.0-alpha.11)'));
console.log(chalk.green('Starting Pongo Shell (version: 0.16.0)'));

const connectionString =
options.connectionString ??
Expand Down
2 changes: 1 addition & 1 deletion src/packages/pongo/src/core/collection/pongoCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
type SQLExecutor,
type SQLMigration,
} from '@event-driven-io/dumbo';
import { v4 as uuid } from 'uuid';
import { v7 as uuid } from 'uuid';
import {
expectedVersionValue,
operationResult,
Expand Down
2 changes: 2 additions & 0 deletions src/packages/pongo/src/core/typing/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
type SQL,
type SQLExecutor,
} from '@event-driven-io/dumbo';
import { v7 as uuid } from 'uuid';
import { ConcurrencyError } from '../errors';

export interface PongoClient {
Expand Down Expand Up @@ -220,6 +221,7 @@ export interface PongoCollection<T extends PongoDocument> {
}

export type ObjectId = string & { __brandId: 'ObjectId' };
export const ObjectId = (value?: string) => value ?? uuid();

export type HasId = { _id: string };

Expand Down
2 changes: 1 addition & 1 deletion src/packages/pongo/src/e2e/compatibilityTest.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
MongoClient as OriginalMongoClient,
} from 'mongodb';
import { after, before, describe, it } from 'node:test';
import { v4 as uuid } from 'uuid';
import { v7 as uuid } from 'uuid';
import { MongoClient, type Db } from '../shim';

type History = { street: string };
Expand Down
2 changes: 1 addition & 1 deletion src/packages/pongo/src/e2e/postgres.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import assert from 'assert';
import console from 'console';
import { after, before, describe, it } from 'node:test';
import { v4 as uuid } from 'uuid';
import { v7 as uuid } from 'uuid';
import {
pongoClient,
type ObjectId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import assert from 'assert';
import console from 'console';
import { after, before, beforeEach, describe, it } from 'node:test';
import { v4 as uuid } from 'uuid';
import { v7 as uuid } from 'uuid';
import {
pongoClient,
pongoSchema,
Expand Down