Skip to content

Quickstart

  1. Open a database in the app (or create one from the Client CRM template, which the examples in these docs use).

  2. Create a connection string. Click Connect at the top of the database (on phones: ⋯ → Connect an app (API)), give it a name such as My script, choose Read & write, and click Create.

    Copy the connection string now: it is shown only once. It looks like this:

    drivedb://kid_7f3k2m9qx4b8w1zt:sk_Q2x…@your-app-domain/f32bf3kwsrxt9dpg

    Keep it secret, like a password. Put it in an environment variable:

    .env
    DRIVEDB_URL=drivedb://kid_…:sk_…@your-app-domain/f32bf3kwsrxt9dpg
  3. Install the SDK.

    Terminal window
    npm install @faeizfurqan/drivedb
  4. Read and write.

    index.ts
    import { DriveDB } from '@faeizfurqan/drivedb';
    // The connection string from "Connect an app", kept out of your code.
    const client = new DriveDB(process.env.DRIVEDB_URL!);
    const db = client.db();
    const clients = db.collection('clients');
    // Create
    const { insertedId } = await clients.insertOne({
    name: 'Ada Lovelace',
    company: 'Analytical Engines',
    status: 'Lead',
    dealValue: 4800,
    });
    // Read
    const leads = await clients.find({ status: 'Lead' }).sort({ dealValue: -1 }).toArray();
    console.log(`${leads.length} leads; the biggest is ${leads[0]?.name}`);
    // Update
    await clients.updateOne({ _id: insertedId }, { $set: { status: 'Won' }, $inc: { dealValue: 200 } });
    // Delete
    await clients.deleteOne({ _id: insertedId });

    Run it with Node.js 22.18 or newer, which runs TypeScript files directly and reads .env files itself:

    Terminal window
    node --env-file=.env index.ts
  5. Look at the app. The records your code writes appear in the grid within seconds.

Every method is a POST with a JSON body, so any language works. Use the key part of the connection string (kid_…:sk_…) as a bearer token:

Terminal window
curl https://your-app-domain/v1/db/f32bf3kwsrxt9dpg/find \
-H "Authorization: Bearer $DRIVEDB_KEY" \
-H "Content-Type: application/json" \
-d '{"collection":"clients","filter":{"status":"Lead"},"limit":10}'

Made by Faeiz Furqan