Custom

Create Custom DbClient

import { StorageClient } from "@cloud-push/cloud";

const dbClient: DbClient = {
  create: () => {},
  delete: () => {},
  find: () => {},
  findAll: () => {},
  readAll: () => {},
  toUint8Array: () => {},
  update: () => {},
};

create

create({ bundle }: { bundle: Bundle }): Promise<void>

Inserts the given bundle object into the Supabase table. Throws an error if the operation fails.


readAll

readAll(): Promise<Bundle[]>

Retrieves all records from the table and returns them as an array of Bundle. Throws an error on failure.


find

find({ conditions }: { conditions: FindCondition<Bundle> }): Promise<Bundle | null>

Finds the first Bundle that matches the given conditions. Returns null if no match is found. Other errors are thrown as is.


findAll

findAll({
  conditions,
  sortOptions,
}: {
  conditions: FindCondition<Bundle>;
  sortOptions?: SortOption<Bundle>[];
}): Promise<Bundle[]>

Finds multiple Bundle records matching the given conditions, optionally applying sorting based on the provided fields and directions.


update

update({ bundle }: { bundle: Bundle }): Promise<void>

Updates the existing record whose bundleId matches the given bundle.


delete

delete({ bundleId }: { bundleId: string }): Promise<void>

Deletes the record from Supabase that matches the given bundleId.


toUint8Array

toUint8Array(): Promise<Uint8Array>

Retrieves all bundle records, serializes them to JSON, and encodes them as a Uint8Array.


Examples

import { defineConfig } from "@cloud-push/cli";
import { StorageClient } from "@cloud-push/cloud";


export default defineConfig(() => ({
  	loadClients: () => {
        
      const storageClient: StorageClient = {
          getFile: () => {},
          getFileSignedUrl: () => {},
          uploadDirectory: () => {},
          uploadFile: () => {},
          uploadLocalFile: () => {},
      };

      const dbClient: DbClient = {
        create: () => {},
        delete: () => {},
        find: () => {},
        findAll: () => {},
        readAll: () => {},
        toUint8Array: () => {},
        update: () => {},
      };

      return {
        storage: storageClient,
        db: dbClient,
      };
	},
}));