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

Referencing a collection in Flutter

Use Koolbase.db.collection('name') to get a reference to a collection. The collection must already exist in your project.

lib/database.dartDart
// Get a collection reference
final posts = Koolbase.db.collection('posts');

// All operations are performed on this reference
await posts.insert({'title': 'Hello'});
final records = await posts.get();

Collection must exist

Calling Koolbase.db.collection('name') on a collection that doesn't exist in your project will return a 404 error on the first operation. Always create collections from the dashboard first.