Adamite
  • Initial page
  • Server
    • Introduction
    • Database
      • Configuration
      • Using different adapters
        • Memory Adapter
      • Securing your data
        • Securing read operations
    • Functions
      • Invokable Functions
      • Runtime Functions
      • Scheduled Functions
  • SDK
    • Introduction
    • Database
      • Introduction
      • Read a document
      • Read multiple documents
      • Subscribe to changes
      • Create a new document
      • Update an existing document
      • Delete a document
    • Authentication
      • Create a user
      • Log in and log out
      • Get the logged in user
    • Functions
      • Invoke a function
Powered by GitBook
On this page

Was this helpful?

  1. Server
  2. Database

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.

PreviousMemory AdapterNextSecuring read operations

Last updated 5 years ago

Was this helpful?