Introduction
Databases in SOAJS are dynamic Registry entries. Each database is linked to a cluster and altogether form up the configuration that the database client connector needs to establish and maintain the database connection.
Objective
Manage Databases
This modules provides wizards to create and manage databases entries inside the registry.
Managing databases is very easy with SOAJS, each database requires a name, the cluster it should use, an optional prefix and simply specify if it is a standalone or multitenant database.
Once Created, SOAJS will provide the databases via the registry object at runtime: req.soajs.registry.
If you are using MongoDB as a database, you can use the SOAJS Mongo Client Driver and benefit from communicating with multitenant and standalone databases. Click here to learn more.
List Databases | Add New Database |
---|---|
Prefix
You can add a global prefix to your databases, by default the value is empty. When adding a database, if you leave the custom prefix empty, the database will get the global prefix.
If you enter a prefix, the prefix is automatically added to the database name when you request the registry information from SOAJS.
EX:
Prefix: test_
Database: myDatabase
Result:
{ "test_myDatabase": { "prefix": "test_", "servers": [{ "host": "127.0.0.1", "port": 27017 }], "credentials": null, "streaming": {}, "URLParam": { "connectTimeoutMS": 0, "socketTimeoutMS": 0, "maxPoolSize": 5, "wtimeoutMS": 0, "slaveOk": true }, "registryLocation": { "l1": "coreDB", "l2": "myDatabase", "env": "dev" }, "name": "myDatabase" } }
Session
Connecting to a Database
Once a database has been created, you can connect to it in your code by fetching its entry from the Registry.
Grab the Database entry from the registry and pass it to your Client Driver. If your database is a MongoDB, you can use the SOAJS Mongo Client (examples available).
Add Comment