Database
User

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 the ORM 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>>;
🔒
Auth: App User

Create a new entry in the table for the given application and returns the created entry.

Parameters

ParameterDescription
appIdThe application ID.
appEnvThe application environment.
appTableThe database table name.
dataAn 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>
🔒
Auth: App User

Create multiple new entries in the table for the given application and returns an object with created count information.

Parameters

ParameterDescription
appIdThe application ID.
appEnvThe application environment.
appTableThe database table name.
dataAn 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>;
🔒
Auth: App User

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

ParameterDescription
appIdThe application ID.
appEnvThe application environment.
appTableThe database table name.
whereAn 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>
🔒
Auth: App User

Delete all matching entries in the table for the given application then returns an object with created count information.

Parameters

ParameterDescription
appIdThe application ID.
appEnvThe application environment.
appTableThe database table name.
whereAn 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>>;
🔒
Auth: App User

Find the first entry in the table for the given application and returns the selection.

Parameters

ParameterDescription
appIdThe application ID.
appEnvThe application environment.
appTableThe database table name.
selectThe object selector.
whereAn 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>>;
🔒
Auth: App User

Find many entries in the table for the given application then returns the selection.

Parameters

ParameterDescription
appIdThe application ID.
appEnvThe application environment.
appTableThe database table name.
selectThe object selector.
whereAn object to target the entry you need.
takeThe number of entries in the response.
skipThe number of entries to skip.
orderByIt 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>>;
🔒
Auth: App User

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

ParameterDescription
appIdThe application ID.
appEnvThe application environment.
appTableThe database table name.
dataThe data object.
whereAn 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>;
🔒
Auth: App User

Update all matching entries in the table for the given application then returns an object with created count information.

Parameters

ParameterDescription
appIdThe application ID.
appEnvThe application environment.
appTableThe database table name.
dataThe data object.
whereAn object to target the entries.