The SecrecyDbClient user instance is instancied with a Schema
extending
DatabaseSchema
. This schema is crucial for defining pseudo query builder
types. Each user method incorporates two default generic arguments:
AppEnv
: A key within the generic parameter Schema of SecrecyDbClient.AppTable
: A key within the object retrieved using the AppEnv generic argument.
If the method contain a select parameter, a third Select
argument is included
to define the response type.
Database User
For
data
,select
,where
,orderBy
,take
,skip
informations see theORM
section.
create()
client.db<Schema>.create<
AppEnv extends keyof Schema,
AppTable extends keyof Schema[AppEnv],
>(
{
appId,
appEnv,
appTable,
data,
}: ORM.CreateInput<Schema, AppEnv, AppTable>,
): Promise<ORM.CreateOutput<Schema, AppEnv, AppTable>>;
Create a new entry in the table for the given application and returns the created entry.
Parameters
Parameter | Description |
---|---|
appId | The application ID. |
appEnv | The application environment. |
appTable | The database table name. |
data | An data object. |
createMany()
client.db<Schema>.createMany<
AppEnv extends keyof Schema,
AppTable extends keyof Schema[AppEnv],
>(
{
appId,
appEnv,
appTable,
data,
}: ORM.CreateManyInput<Schema, AppEnv, AppTable>,
): Promise<ORM.CreateManyOutput>
Create multiple new entries in the table for the given application and returns an object with created count information.
Parameters
Parameter | Description |
---|---|
appId | The application ID. |
appEnv | The application environment. |
appTable | The database table name. |
data | An array of object to create the entries |
delete()
client.db<Schema>.delete<
AppEnv extends keyof Schema,
AppTable extends keyof Schema[AppEnv],
>(
{
appId,
appEnv,
appTable,
where,
}: ORM.DeleteInput<Schema, AppEnv, AppTable>,
): Promise<ORM.DeleteOutput>;
Delete the first matching entry in the table for the given application then returns an object with created count information. An error is thrown if no entry is found.
Parameters
Parameter | Description |
---|---|
appId | The application ID. |
appEnv | The application environment. |
appTable | The database table name. |
where | An object to target the entry to delete. |
deleteMany()
client.db<Schema>.deleteMany<
AppEnv extends keyof Schema,
AppTable extends keyof Schema[AppEnv],
>(
{
appId,
appEnv,
appTable,
where,
}: ORM.DeleteManyInput<Schema, AppEnv, AppTable>,
): Promise<ORM.DeleteManyOutput>
Delete all matching entries in the table for the given application then returns an object with created count information.
Parameters
Parameter | Description |
---|---|
appId | The application ID. |
appEnv | The application environment. |
appTable | The database table name. |
where | An object to target the entries to delete. |
findFirst()
client.db<Schema>.findFirst<
AppEnv extends keyof Schema,
AppTable extends keyof Schema[AppEnv],
Select extends ORM.DatabaseSelectArg<Schema[AppEnv][AppTable]>,
>(
{
appId,
appEnv,
appTable,
select,
where,
}: ORM.FindFirstInput<Schema, AppEnv, AppTable, Select>,
): Promise<ORM.FindFirstOutput<Schema, AppEnv, AppTable, Select>>;
Find the first entry in the table for the given application and returns the selection.
Parameters
Parameter | Description |
---|---|
appId | The application ID. |
appEnv | The application environment. |
appTable | The database table name. |
select | The object selector. |
where | An object to target the entry you need. |
findMany()
client.db<Schema>.findMany<
AppEnv extends keyof Schema,
AppTable extends keyof Schema[AppEnv],
Select extends ORM.DatabaseSelectArg<Schema[AppEnv][AppTable]>,
>(
{
appId,
appEnv,
appTable,
select,
where,
take,
skip,
orderBy
}: ORM.FindManyInput<Schema, AppEnv, AppTable, Select>,
): Promise<ORM.FindManyOutput<Schema, AppEnv, AppTable, Select>>;
Find many entries in the table for the given application then returns the selection.
Parameters
Parameter | Description |
---|---|
appId | The application ID. |
appEnv | The application environment. |
appTable | The database table name. |
select | The object selector. |
where | An object to target the entry you need. |
take | The number of entries in the response. |
skip | The number of entries to skip. |
orderBy | It allows you to specify an order in the selection of your elements and sort them. It works in the same way as Prisma, meaning you need to use an asc or desc tag assigned to a property. Example: { orderBy: { date: 'desc' } } |
update()
client.db<Schema>.update<
AppEnv extends keyof Schema,
AppTable extends keyof Schema[AppEnv],
Select extends ORM.DatabaseSelectArg<Schema[AppEnv][AppTable]>,
>(
{
appId,
appEnv,
appTable,
data,
select,
where,
}: ORM.UpdateInput<Schema, AppEnv, AppTable, Select>,
): Promise<ORM.UpdateOutput<Schema, AppEnv, AppTable, Select>>;
Update the first matching entry in the table for the given application id and environment then returns the selection. An error is thrown if no entry is found.
Parameters
Parameter | Description |
---|---|
appId | The application ID. |
appEnv | The application environment. |
appTable | The database table name. |
data | The data object. |
where | An object to target the entry. |
updateMany()
client.db<Schema>.updateMany<
AppEnv extends keyof Schema,
AppTable extends keyof Schema[AppEnv],
>(
{
appId,
appEnv,
appTable,
data,
where,
}: ORM.UpdateManyInput<Schema, AppEnv, AppTable>,
): Promise<ORM.UpdateManyOutput>;
Update all matching entries in the table for the given application then returns an object with created count information.
Parameters
Parameter | Description |
---|---|
appId | The application ID. |
appEnv | The application environment. |
appTable | The database table name. |
data | The data object. |
where | An object to target the entries. |