Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

SSQL

import { SSQL } from "https://raw.githubusercontent.com/cybertim/SmallSQLiteORM/main/mod.ts";

ORM Wrapper to interact with deno.land/x/sqlite using your SSQLTable

class SSQL {
constructor(
dbName: string,
entities: (new () => SSQLTable)[],
defaults?: SSQLDefaults,
);
private defaults: SSQLDefaults;
public db: DB;
 
private alterTable<T extends SSQLTable>(table: T, columns: string[]);
private columnInfo<T extends SSQLTable>(table: T, column: string);
private createTable<T extends SSQLTable>(table: T);
private find<T extends SSQLTable>(
table: (new () => T),
query: SSQLQuery,
countOnly?: boolean,
): {
count: number;
objects: T[];
}
;
private insertRecord<T extends SSQLTable>(table: T);
private updateRecord<T extends SSQLTable>(table: T);
public count<T extends SSQLTable>(table: (new () => T));
public countBy<T extends SSQLTable>(table: (new () => T), query: SSQLQuery);
public delete<T extends SSQLTable>(obj: T);
public findMany<T extends SSQLTable>(table: (new () => T), query: SSQLQuery);
public findOne<T extends SSQLTable>(table: (new () => T), id: number);
public save<T extends SSQLTable>(obj: T);
}

§Constructors

§
new SSQL(dbName: string, entities: (new () => SSQLTable)[], defaults?: SSQLDefaults)
[src]

Create an instance of SSQL

const orm = new SSQL("test.db", [User]);
@param dbName

the name of the database file on disk used by sqlite

@param entities

array of all models extending SSQLTable

@param defaults

optional configuration to override DEFAULT vaules of columns by type

§Properties

§Methods

§
alterTable<T extends SSQLTable>(table: T, columns: string[]) private
[src]
§
columnInfo<T extends SSQLTable>(table: T, column: string) private
[src]
§
createTable<T extends SSQLTable>(table: T) private
[src]
§
find<T extends SSQLTable>(table: (new () => T), query: SSQLQuery, countOnly?: boolean): {
count: number;
objects: T[];
}
private
[src]
§
insertRecord<T extends SSQLTable>(table: T) private
[src]
§
updateRecord<T extends SSQLTable>(table: T) private
[src]
§
count<T extends SSQLTable>(table: (new () => T))
[src]

COUNT(*) on all records in the table given

@param table
§
countBy<T extends SSQLTable>(table: (new () => T), query: SSQLQuery)
[src]

COUNT(*) on all records in the table given matching the SSQLQuery query object

@param table
@param query
§
delete<T extends SSQLTable>(obj: T)
[src]

DELETE the obj from the SQLite database

@param obj

model based on SSQLTable

§
findMany<T extends SSQLTable>(table: (new () => T), query: SSQLQuery)
[src]
const users = orm.findMany(User, { where: { clause: "username = ?", values: [username] }});
@param table
@param query
§
findOne<T extends SSQLTable>(table: (new () => T), id: number)
[src]

SELECT * FROM table and return model WHERE id equals given id

const user = orm.findOne(User, 1);
@param table
@param id

id to match with SSQLTable

§
save<T extends SSQLTable>(obj: T)
[src]

INSERT or UPDATE the obj based on the id (INSERT when -1 else UPDATE)

@param obj

model based on SSQLTable