Skip to main content
Module

x/cotton/src/utils/models.ts

SQL Database Toolkit for Deno
Latest
import * as cotton from "https://deno.land/x/cotton@v0.7.5/src/utils/models.ts";

Functions

Compare the current values against the last saved data

Transform single plain JavaScript object to Model class.

Transform an array of plain JavaScript objects to multiple Model classes.

Find a single column information from a model. This can be used to get select: false column which you cannot get from getColumns by default.

Get all column definitions from a model.

Get data type from type metadata.

Normalize value to a database compatible values.

Update the isSaved status of a model and save the original value.

Get the primary key column information from a model.

Get all relationship definitions from a model.

Get relational values in a model.

Get the table name from a model.

Get model values as a plain JavaScript object

Check wether this model is saved to the database.

Map the query builder result for creating a model.

Map a single record from the query builder result for creating a model.

Map values from getValues to be compatible with model properties vice versa.

Update the isSaved status of a model, save the original value, and populate model with default values.