@duraxis/orm 0.1.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,8 @@
1
1
  import type { DuraxisDatabase, Transaction } from "@duraxis/core";
2
+ import type { MetadataRegistry } from "../metadata/metadata-registry.js";
2
3
  export interface RepositoryRuntime {
3
4
  readonly database: DuraxisDatabase;
4
5
  readonly transaction?: Transaction;
5
6
  readonly assertUsable: () => void;
7
+ readonly registry: MetadataRegistry;
6
8
  }
@@ -1,7 +1,8 @@
1
1
  import type { EntityMetadata } from "../metadata/entity-metadata.js";
2
- import type { FindOptions, FindPage } from "../query/find-options.js";
2
+ import type { FindOptions, FindPage, Relations } from "../query/find-options.js";
3
3
  import { QueryBuilder } from "../query/query-builder.js";
4
4
  import type { RepositoryRuntime } from "./repository-options.js";
5
+ import { RelationOperations } from "../relations/relation-operations.js";
5
6
  export declare class Repository<TEntity extends object> {
6
7
  #private;
7
8
  readonly metadata: EntityMetadata<TEntity>;
@@ -13,14 +14,20 @@ export declare class Repository<TEntity extends object> {
13
14
  update(id: string, changes: Partial<TEntity>): Promise<TEntity>;
14
15
  upsert(entity: TEntity): Promise<TEntity>;
15
16
  delete(id: string): Promise<boolean>;
16
- findById(id: string): Promise<TEntity | null>;
17
+ findById(id: string, options?: {
18
+ readonly relations?: Relations<TEntity>;
19
+ readonly signal?: AbortSignal;
20
+ }): Promise<TEntity | null>;
17
21
  findOne(options?: FindOptions<TEntity>): Promise<TEntity | null>;
18
22
  find(options?: FindOptions<TEntity>): Promise<readonly TEntity[]>;
19
23
  findPage(options: FindOptions<TEntity>): Promise<FindPage<TEntity>>;
20
24
  exists(options?: FindOptions<TEntity>): Promise<boolean>;
21
25
  count(options?: Pick<FindOptions<TEntity>, "where" | "signal">): Promise<number>;
22
26
  createQueryBuilder(): QueryBuilder<TEntity>;
27
+ relations<K extends Extract<keyof TEntity, string>>(property: K): RelationOperations<TEntity>;
23
28
  private hydrate;
29
+ private loadRelations;
30
+ private mapFind;
24
31
  private queryRows;
25
32
  private queryPage;
26
33
  private sourceQuery;
@@ -1,3 +1,4 @@
1
1
  import type { CollectionDefinition } from "@duraxis/core";
2
2
  import type { EntityMetadata } from "../metadata/entity-metadata.js";
3
3
  export declare function mapEntitySchema(metadata: EntityMetadata): CollectionDefinition;
4
+ export declare function mapJunctionSchemas(metadata: readonly EntityMetadata[]): readonly CollectionDefinition[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duraxis/orm",
3
- "version": "0.1.0",
3
+ "version": "0.2.2",
4
4
  "description": "Decorator-based entity mapping and repositories for the Duraxis database.",
5
5
  "license": "ISC",
6
6
  "author": "João Paulo Dias <joaopdias.dev@gmail.com>",
@@ -45,12 +45,12 @@
45
45
  "CHANGELOG.md"
46
46
  ],
47
47
  "dependencies": {
48
- "@duraxis/core": "0.1.0"
48
+ "@duraxis/core": "0.2.2"
49
49
  },
50
50
  "devDependencies": {
51
- "@duraxis/storage": "0.1.0",
52
- "@duraxis/storage-memory": "0.1.0",
53
- "@duraxis/storage-disk": "0.1.0"
51
+ "@duraxis/storage": "0.1.2",
52
+ "@duraxis/storage-memory": "0.1.3",
53
+ "@duraxis/storage-disk": "0.1.3"
54
54
  },
55
55
  "scripts": {
56
56
  "build": "vite build && tsc -p tsconfig.build.json",