diff --git a/app/package.json b/app/package.json index 2d85879..749208e 100644 --- a/app/package.json +++ b/app/package.json @@ -3,7 +3,7 @@ "type": "module", "sideEffects": false, "bin": "./dist/cli/index.js", - "version": "0.15.0-rc.0", + "version": "0.15.0-rc.2", "description": "Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.", "homepage": "https://bknd.io", "repository": { diff --git a/app/src/data/entities/mutation/Mutator.ts b/app/src/data/entities/mutation/Mutator.ts index a270c7a..2e01cfe 100644 --- a/app/src/data/entities/mutation/Mutator.ts +++ b/app/src/data/entities/mutation/Mutator.ts @@ -125,10 +125,13 @@ export class Mutator< // if listener returned, take what's returned const _data = result.returned ? result.params.data : data; - let validatedData = { - ...entity.getDefaultObject(), - ...(await this.getValidatedData(_data, "create")), - }; + let validatedData = await this.getValidatedData( + { + ...entity.getDefaultObject(), + ..._data, + }, + "create", + ); // check if required fields are present const required = entity.getRequiredFields(); @@ -289,10 +292,6 @@ export class Mutator< ): Promise> { const entity = this.entity; const validatedData = await this.getValidatedData(data, "update"); - console.log("updateWhere", { - entity, - validatedData, - }); // @todo: add a way to delete all by adding force? if (!where || typeof where !== "object" || Object.keys(where).length === 0) { diff --git a/app/src/data/entities/mutation/MutatorResult.ts b/app/src/data/entities/mutation/MutatorResult.ts index b5ad083..05da017 100644 --- a/app/src/data/entities/mutation/MutatorResult.ts +++ b/app/src/data/entities/mutation/MutatorResult.ts @@ -2,6 +2,7 @@ import { $console } from "core/console"; import type { Entity, EntityData } from "../Entity"; import type { EntityManager } from "../EntityManager"; import { Result, type ResultJSON, type ResultOptions } from "../Result"; +import { isDebug } from "core"; export type MutatorResultOptions = ResultOptions & { silent?: boolean; @@ -16,13 +17,15 @@ export class MutatorResult extends Result { public entity: Entity, options?: MutatorResultOptions, ) { + const logParams = options?.logParams === undefined ? isDebug() : options.logParams; + super(em.connection, { hydrator: (rows) => em.hydrate(entity.name, rows as any), beforeExecute: (compiled) => { if (!options?.silent) { $console.debug( `[Mutation]\n${compiled.sql}\n`, - options?.logParams ? compiled.parameters : undefined, + logParams ? compiled.parameters : undefined, ); } }, diff --git a/app/src/ui/routes/data/data.$entity.$id.tsx b/app/src/ui/routes/data/data.$entity.$id.tsx index be8bc34..978573a 100644 --- a/app/src/ui/routes/data/data.$entity.$id.tsx +++ b/app/src/ui/routes/data/data.$entity.$id.tsx @@ -19,6 +19,10 @@ import { EntityTable2 } from "ui/modules/data/components/EntityTable2"; import { useEntityForm } from "ui/modules/data/hooks/useEntityForm"; export function DataEntityUpdate({ params }) { + return ; +} + +function DataEntityUpdateImpl({ params }) { const { $data, relations } = useBkndData(); const entity = $data.entity(params.entity as string); if (!entity) { @@ -240,7 +244,12 @@ function EntityDetailRelations({ })} />
- +
); @@ -257,6 +266,7 @@ function EntityDetailInner({ }) { const other = relation.other(entity); const [navigate] = useNavigate(); + const [search, setSearch] = useState({ select: other.entity.getSelect(undefined, "table"), sort: other.entity.getDefaultSort(), diff --git a/app/src/ui/routes/data/data.$entity.index.tsx b/app/src/ui/routes/data/data.$entity.index.tsx index dfb3ede..7b23fee 100644 --- a/app/src/ui/routes/data/data.$entity.index.tsx +++ b/app/src/ui/routes/data/data.$entity.index.tsx @@ -26,6 +26,10 @@ const searchSchema = s.partialObject({ const PER_PAGE_OPTIONS = [5, 10, 25, 50, 100]; export function DataEntityList({ params }) { + return ; +} + +function DataEntityListImpl({ params }) { const { $data } = useBkndData(); const entity = $data.entity(params.entity as string); if (!entity) {