Securing your data

By default Adamite doesn't enforce security on the database. When you're ready to configure security, you can do so with database rules.

Adamite allows you to secure your database using rules. By default, your database's rules file is located in database/rules.js.

module.exports = {
  "default": {
    
  }
};

To begin adding rules, you'll want to specify a collection and an operation to secure in the rules.js file.

module.exports = {
  "default": {
    "projects": {
      "read": () => {
        return true;
      }
    }
  }
};

Now, when anyone attempts to read a document in the projects collection, the function specified will be executed first and must return true to allow the operation to proceed.

To prevent the operation from proceeding, you can either return false or throw an Error which will be sent back to the client.

Last updated