swc/crates/swc_bundler/tests/.cache/deno/635cf8b09e7ff6a6ed019da4e7138ffcc79f40d3.ts
2021-11-09 20:42:49 +09:00

21 lines
508 B
TypeScript

// Loaded from https://deno.land/x/denodb@v1.0.18/lib/helpers/results.ts
import type { ModelSchema } from "../model.ts";
import type { Values } from "../data-types.ts";
/** Transform a plain record object to a given model schema. */
export function formatResultToModelInstance(
Schema: ModelSchema,
fields: Values,
) {
const instance = new Schema();
for (const field in fields) {
(instance as any)[Schema.formatFieldToClient(field) as string] =
fields[field];
}
return instance;
}