Lowdb

LowdbClient

The LowdbClient helps manage versioning of bundles using a JSON file. It is designed to work alongside a storageClient.

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

const dbClient = new LowDbClient({
  downloadJSONFile: () => storageClient.getFile({ key: "cursor.json" }),
  uploadJSONFile: (file: Uint8Array) =>
    storageClient.uploadFile({ key: "cursor.json", file }),
});

downloadJSONFile

downloadJSONFile(): Promise<void>

Downloads the JSON file used for version management.


uploadJSONFile

uploadJSONFile(file: Uint8Array): Promise<void>

Uploads the JSON file used for version management.


Examples

import { defineConfig } from "@cloud-push/cli";
import { AWSS3StorageClient, LowDbClient } from "@cloud-push/cloud";


export default defineConfig(() => ({
  loadClients: () => {
		
    const storageClient = new AWSS3StorageClient({
      accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
      bucketName: process.env.AWS_BUCKET_NAME!,
      region: process.env.AWS_REGION!,
      secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
    });

    const dbClient = new LowDbClient({
      downloadJSONFile: () => storageClient.getFile({ key: "cursor.json" }),
      uploadJSONFile: (file: Uint8Array) =>
        storageClient.uploadFile({ key: "cursor.json", file }),
    });

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