Home » AI Databases » Custom App Data

How to Store Custom App Data in NoSQL

When you build a custom app on the platform, the built-in NoSQL database is the simplest way to store your app's data. Your app's code can read, write, update, and delete records using the same key-value store that powers the platform itself, with no external database setup required and every operation costing just 1-2 credits.

How Custom Apps Access the Database

Custom apps built on the platform run as server-side PHP code with direct access to the database functions. Your app code can call the same database operations used by the platform's built-in features: insert a record, read a record by key, query all records under a partition key, update individual fields, or delete records.

The NoSQL store uses a two-key system. Your app defines the partition key (to group related records) and the sort key (to identify individual records). You choose whatever naming convention makes sense for your app. For example, a CRM app might use the company ID as the partition key with contact IDs as sort keys. A project tracker might use project IDs with task IDs.

Step-by-Step: Storing Data in Your Custom App

Step 1: Plan your data model.
Decide what data your app needs to store and how to organize it. Think about what you will look up most often, since the partition key is your primary access path. If you mainly look up data by user, the user ID is a good partition key. If you mainly look up data by project, the project ID is better.
Step 2: Write data from your app code.
Use the database insert function in your custom app to create records. Pass the partition key, sort key, and a JSON data object. The record is stored immediately and available for retrieval. Your app code handles this in its command functions, typically when processing a form submission or API request.
Step 3: Read data back.
Fetch a single record by specifying both keys, or query all records under a partition key. For example, fetch all contacts for a company by querying with the company ID as the partition key. The results come back as a JSON array that your app can loop through and display.
Step 4: Update records.
Update individual fields on existing records without rewriting the entire object. This is efficient for status changes, counters, and incremental updates. Your app code can update just the fields that changed, leaving everything else untouched.
Step 5: Build admin pages for the data.
Use the platform's admin slug system to create management pages for your app data. The slug configuration defines which fields to show in the list view, what the edit form looks like, and how to create and delete records. The admin system handles the UI while your app code handles the business logic.

Data Model Examples

CRM App

Partition key: company ID. Sort keys: "contact-001", "contact-002", etc. for contacts, "deal-001", "deal-002" for deals, and "settings" for company-level configuration. Query all records under a company ID to get everything related to that account.

Booking App

Partition key: business ID. Sort keys: "booking-20260319-1000" (date and time), "client-abc" for client records, "service-haircut" for service definitions. The date-based sort keys make it easy to query bookings for a specific date range.

Inventory App

Partition key: warehouse or store ID. Sort keys: product SKUs. Each record holds the product name, quantity, price, and location. Query all products in a warehouse by the partition key, or fetch a specific product by its SKU sort key.

Storage costs: The NoSQL database charges 1-2 credits per operation (read or write). There are no monthly storage fees. A custom app that performs 1,000 database operations per day costs about $1-2 per month in credits, making it extremely affordable for small and medium applications.

When to Use NoSQL vs External SQL

Use the built-in NoSQL for most custom apps, especially those that need simple data storage without complex queries. If your app requires complex SQL joins, aggregate reporting across large datasets, or compatibility with existing SQL databases, connect a MySQL or PostgreSQL database instead. Many apps use both: NoSQL for fast operational data and SQL for analytical queries.

Build custom apps with built-in data storage. No database setup, no hosting, just build and deploy.

Get Started Free