16 Managing Collections
Oracle Backend for Firebase supports a document-oriented data model where collections serve as containers for documents. This section outlines the Console-based and REST API operations for managing collections within an Oracle Backend for Firebase project.
- Prerequisites for Collection Management
- Collections and Documents
- Creating a Collection
- Dropping a Collection
- Getting a Collection List
Parent topic: Database
16.1 Prerequisites for Collection Management
Before performing collection-level operations such as creating, dropping, or listing collections, ensure the following:
-
Project Initialization: The Oracle Backend for Firebase project must be created and configured using the Console.
-
Authentication Setup: The application must be initialized using
initializeApp()or equivalent. A valid Auth token must be included in all requests. -
SDK Installation: The relevant SDK (JS, Android, iOS) must be installed and configured with the correct
config.json. -
Database Configuration:
-
For collection model: Ensure that the collection name follows naming conventions and is not reserved.
-
For relational model: Ensure that the relational table is mapped and duality views are configured if applicable.
-
-
Security Rules: Appropriate rules must be published to allow
create,delete, orlistoperations on collections. -
User Role: The authenticated user must have privileges to manage collections (typically an Oracle Backend for Firebase database user with privileges for executing commands such as
CREATE TABLEandDROP TABLE).
Parent topic: Managing Collections
16.2 Collections and Documents
Collections
Collections are logical containers for documents, similar to a table in relational databases. Collections can be nested, grouped, or standalone. They can be created implicitly by writing to a new path or explicitly using the Console or REST API.
Document
A document is a JSON object stored within a collection. Each document has a unique ID and can contain nested fields, arrays, and even subcollections. For example:
{
"EmployeeID": "2",
"FirstName": "John",
"LastName": "Morrow",
"Email": "john.morrow@example.com"
}
Subcollections
Documents can contain child collections, allowing hierarchical data modeling. For
example, a User document might have a subcollection
Orders.
Collection Groups
These are sets of collections with the same name but located at different paths. They allow querying across multiple collections simultaneously, which is useful for multi-tenant or multi-project setups.
Parent topic: Managing Collections
16.3 Creating a Collection
In Oracle Backend for Firebase, collections can be created by both developers and administrators, but through different interfaces and with different levels of control.
A developer does not need to create a collection explicitly. When a
developer creates a document using an SDK (setDoc() or
addDoc()), REST API (sending POST request to
document endpoint), or Console UI (using the database page to create documents), and
writes a document path (for example, Cities/City1), Oracle Backend for
Firebase automatically creates the collection Cities, if it doesn't
exist.
An administrator can use the Console UI in Oracle Backend for Firebase to explicitly create a collection.
Using Console UI
-
Access the Oracle Backend for Firebase Console UI and navigate to the Database section.
-
Choose the active project where you want to create the collection.
-
Select Create Collection and use the UI form to input the collection name and optionally configure metadata like type (
docorrelational), indexing preferences, and access rules. -
Select the model type:
-
For JSON-based: No schema required.
-
For Hybrid: Map to an existing relational table.
-
-
Click Create.
The backend triggers the appropriate REST API (
POST /collection) to create the collection.
Parent topic: Managing Collections
16.4 Dropping a Collection
Dropping a collection in Oracle Backend for Firebase is a privileged operation and is typically performed by administrators, not developers. Developers cannot drop collections because SDKs do not support collection deletion.
Administrators (project owners) can use the Console UI in Oracle Backend for Firebase to drop a collection:
Caution:
Deleting a collection will remove all documents within it.
Using Console UI
-
Access the Oracle Backend for Firebase Console.
-
Navigate to the Database Data section.
-
Select the collection you wish to delete (For example,
Employees). -
Click Delete Collection.
-
Confirm the deletion.
Parent topic: Managing Collections
16.5 Getting a Collection List
You can retrieve all the collections within a project using the Console:
Using Console UI
-
Access the Oracle Backend for Firebase Console.
-
Select your project.
-
Navigate to the Database Data section.
All collections are listed in the UI.
Parent topic: Managing Collections