Collections

Collections are named groups of records — like database tables, but schema-free. Create them from the dashboard before inserting data.

Creating a collection

Collections are created from the Koolbase dashboard. Navigate to your project, select Database, and click New Collection.

When creating a collection you set three access rules:

Read RuleWho can query and fetch records from this collection
Write RuleWho can insert new records into this collection
Delete RuleWho can delete records from this collection

See Access Rules for the full reference.

Naming rules

Collection names must follow these rules:

Lowercase letters, numbers, hyphens, and underscores only
Maximum 63 characters
Must be unique within a project
Examples: posts, user-profiles, order_items

Built-in record fields

Every record automatically gets these fields — you don't need to include them when inserting:

idUUIDUnique identifier, auto-generated
created_atTimestampWhen the record was inserted
updated_atTimestampWhen the record was last updated
created_byUUID | nullUser ID of the creator, if authenticated

Using a collection from the SDK

Name the collection on each call. The collection must already exist in your project.

lib/database.dart
Dart
// Write to it
await Koolbase.db.insert(collection: 'posts', data: {'title': 'Hello'});

// Read from it
final result = await Koolbase.db.collection('posts').get();

Collection must exist

Using a collection that doesn't exist in your project returns a 404 error. Always create collections from the dashboard first.