silvie
Version:
Typescript Back-end Framework
54 lines (53 loc) • 1.75 kB
TypeScript
import ModelQueryBuilder, { IModel } from "./query_builder";
import { TBaseValue } from "../builders/condition";
declare class Model extends ModelQueryBuilder implements IModel {
/**
* Fetch all records from the table
*/
static all(): Promise<Model[]>;
/**
* Find a record in the table with the given id
* @param id
*/
static find(id: TBaseValue | TBaseValue[]): Promise<Model>;
static findAll(...ids: (TBaseValue | TBaseValue[])[]): Promise<Model[]>;
/**
* Insert a single record into the table and return with either created record or InsertedId
* @param data
* @param shouldReturn Specify to return the created record or not, defaults to true
*/
static create(data: any, shouldReturn?: boolean): Promise<Model>;
/**
* Fill this instance with the provided data
* @param data
*/
fill(data: any): void;
/**
* Retrieve a fresh copy of this instance from the database
*/
fresh(): Promise<Model>;
/**
* Refresh the current instance from the database
*/
refresh(): Promise<void>;
/**
* Update the current instance with the provided data
* @param data
* @param silent Weather to refresh the update timestamp or not
*/
update(data: any, silent?: boolean): Promise<number>;
/**
* Delete the current instance (uses soft delete if it is enabled in model)
*/
delete(): Promise<any>;
/**
* Delete the current instance
*/
forceDelete(): Promise<number>;
/**
* Save the changes of current instance in the database
* @param silent Weather to refresh the update timestamp or not
*/
save(silent?: boolean): Promise<number>;
}
export default Model;