[fabric/domain] Rename StoreQuery
This commit is contained in:
parent
558ee2b9bc
commit
307a82d83c
@ -1,5 +1,5 @@
|
|||||||
export * from "./fields/index.ts";
|
export * from "./fields/index.ts";
|
||||||
export * from "./model-schema.ts";
|
export * from "./model-schema.ts";
|
||||||
export * from "./model.ts";
|
export * from "./model.ts";
|
||||||
export * from "./query/index.ts";
|
|
||||||
export * from "./state-store.ts";
|
export * from "./state-store.ts";
|
||||||
|
export * from "./store-query/index.ts";
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import type { AsyncResult } from "@fabric/core";
|
|||||||
import type { StoreQueryError } from "../errors/query-error.ts";
|
import type { StoreQueryError } from "../errors/query-error.ts";
|
||||||
import type { ModelSchemaFromModels } from "./model-schema.ts";
|
import type { ModelSchemaFromModels } from "./model-schema.ts";
|
||||||
import type { Model, ModelToType } from "./model.ts";
|
import type { Model, ModelToType } from "./model.ts";
|
||||||
import type { StoreQuery } from "./query/query.ts";
|
import type { StoreQuery } from "./store-query/store-query.ts";
|
||||||
|
|
||||||
export interface ReadonlyStateStore<TModel extends Model> {
|
export interface ReadonlyStateStore<TModel extends Model> {
|
||||||
from<T extends keyof ModelSchemaFromModels<TModel>>(
|
from<T extends keyof ModelSchemaFromModels<TModel>>(
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
export * from "./filter-options.ts";
|
export * from "./filter-options.ts";
|
||||||
export * from "./order-by-options.ts";
|
export * from "./order-by-options.ts";
|
||||||
export * from "./query.ts";
|
export * from "./store-query.ts";
|
||||||
@ -1,5 +1,10 @@
|
|||||||
// deno-lint-ignore-file no-explicit-any
|
// deno-lint-ignore-file no-explicit-any
|
||||||
import type { AsyncResult, Keyof, Optional } from "@fabric/core";
|
import {
|
||||||
|
type AsyncResult,
|
||||||
|
type Keyof,
|
||||||
|
type Optional,
|
||||||
|
TaggedError,
|
||||||
|
} from "@fabric/core";
|
||||||
import type { StoreQueryError } from "../../errors/query-error.ts";
|
import type { StoreQueryError } from "../../errors/query-error.ts";
|
||||||
import type { FilterOptions } from "./filter-options.ts";
|
import type { FilterOptions } from "./filter-options.ts";
|
||||||
import type { OrderByOptions } from "./order-by-options.ts";
|
import type { OrderByOptions } from "./order-by-options.ts";
|
||||||
@ -18,6 +23,11 @@ export interface StoreQuery<T> {
|
|||||||
selectOne<K extends Keyof<T>>(
|
selectOne<K extends Keyof<T>>(
|
||||||
keys: K[],
|
keys: K[],
|
||||||
): AsyncResult<Optional<Pick<T, K>>, StoreQueryError>;
|
): AsyncResult<Optional<Pick<T, K>>, StoreQueryError>;
|
||||||
|
|
||||||
|
selectOneOrFail(): AsyncResult<T, StoreQueryError | NotFoundError>;
|
||||||
|
selectOneOrFail<K extends Keyof<T>>(
|
||||||
|
keys: K[],
|
||||||
|
): AsyncResult<Pick<T, K>, StoreQueryError | NotFoundError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StoreSortableQuery<T> {
|
export interface StoreSortableQuery<T> {
|
||||||
@ -33,6 +43,11 @@ export interface StoreSortableQuery<T> {
|
|||||||
selectOne<K extends Keyof<T>>(
|
selectOne<K extends Keyof<T>>(
|
||||||
keys: K[],
|
keys: K[],
|
||||||
): AsyncResult<Optional<Pick<T, K>>, StoreQueryError>;
|
): AsyncResult<Optional<Pick<T, K>>, StoreQueryError>;
|
||||||
|
|
||||||
|
selectOneOrFail(): AsyncResult<T, StoreQueryError | NotFoundError>;
|
||||||
|
selectOneOrFail<K extends Keyof<T>>(
|
||||||
|
keys: K[],
|
||||||
|
): AsyncResult<Pick<T, K>, StoreQueryError | NotFoundError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StoreLimitableQuery<T> {
|
export interface StoreLimitableQuery<T> {
|
||||||
@ -47,6 +62,11 @@ export interface StoreLimitableQuery<T> {
|
|||||||
selectOne<K extends Keyof<T>>(
|
selectOne<K extends Keyof<T>>(
|
||||||
keys: K[],
|
keys: K[],
|
||||||
): AsyncResult<Optional<Pick<T, K>>, StoreQueryError>;
|
): AsyncResult<Optional<Pick<T, K>>, StoreQueryError>;
|
||||||
|
|
||||||
|
selectOneOrFail(): AsyncResult<T, StoreQueryError | NotFoundError>;
|
||||||
|
selectOneOrFail<K extends Keyof<T>>(
|
||||||
|
keys: K[],
|
||||||
|
): AsyncResult<Pick<T, K>, StoreQueryError | NotFoundError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SelectableQuery<T> {
|
export interface SelectableQuery<T> {
|
||||||
@ -59,9 +79,14 @@ export interface SelectableQuery<T> {
|
|||||||
selectOne<K extends Keyof<T>>(
|
selectOne<K extends Keyof<T>>(
|
||||||
keys: K[],
|
keys: K[],
|
||||||
): AsyncResult<Optional<Pick<T, K>>, StoreQueryError>;
|
): AsyncResult<Optional<Pick<T, K>>, StoreQueryError>;
|
||||||
|
|
||||||
|
selectOneOrFail(): AsyncResult<T, StoreQueryError | NotFoundError>;
|
||||||
|
selectOneOrFail<K extends Keyof<T>>(
|
||||||
|
keys: K[],
|
||||||
|
): AsyncResult<Pick<T, K>, StoreQueryError | NotFoundError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface QueryDefinition<K extends string = string> {
|
export interface StoreQueryDefinition<K extends string = string> {
|
||||||
from: K;
|
from: K;
|
||||||
where?: FilterOptions<any>;
|
where?: FilterOptions<any>;
|
||||||
orderBy?: OrderByOptions<any>;
|
orderBy?: OrderByOptions<any>;
|
||||||
@ -69,3 +94,9 @@ export interface QueryDefinition<K extends string = string> {
|
|||||||
offset?: number;
|
offset?: number;
|
||||||
keys?: string[];
|
keys?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class NotFoundError extends TaggedError<"NotFoundError"> {
|
||||||
|
constructor() {
|
||||||
|
super("NotFoundError");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user