Local CloudCode Development
The same database API from CloudCode is available in NodeJS for local development. This may be useful for debugging, or long-running tasks that would exceed the memory or time limits of CloudCode, such as large migration tasks.

Setup

Node 8.10 or later is recommended for built-in async-await support.
Install the journeyapps package with yarn or npm:
yarn add journeyapps
npm install journeyapps

Usage

Here is a sample script:
const { Database, Day } = require("journeyapps");
async function run() {
const db = await Database.instance({ baseUrl: 'https://run.journeyapps.com/api/v4/testaccount', token: process.env.API_TOKEN });
let user = await db.user.first();
console.log(user.name);
}
run();
Run the following from your terminal:
export API_TOKEN=O:ABCDE # From the Manage API page
node script.js
Limitations
  • Some CloudCode-specific functionality, such as task context, automatic DB configuration and scheduling tasks, is not available yet. This may be added in future versions.
  • Only v4 apps are supported. V3 apps must be upgraded to v4 before using this package.

Batch API

When making a large number of database updates, it is strongly recommended to use the Batch API, to reduce the overhead per request.

Copy link
On this page
Setup
Usage
Batch API