0.1.6 • Published 3 years ago

strapi-hook-astra v0.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Strapi Hook Astra

Prerequisite

Install node 14.17.3 version

Local Development

Create a Strapi Project:

npx create-strapi-app my-project

Install the hook

Install this hook using: npm i strapi-hook-astra

Activating the hook

Add the following to ./config/hook.js of sample Strapi Project:

module.exports = {
    settings: {
        astra: {
            enabled: true,
            token: 'REPLACE_ME',
            databaseId: 'REPLACE_ME',
            databaseRegion: 'REPLACE_ME',
            keyspace: 'REPLACE_ME',
            collection: 'REPLACE_ME'
        },
    }
};
  • token: Generate a token from Astra DB

  • databaseId: Enter your Astra DB database ID from your database URL.

  • databaseRegion: Enter your Astra DB database region.

  • keyspace: Enter your Astra DB keyspace name.

  • collection: Enter your Astra DB collection name.

Usage

  • Create document:

strapi.services.astra.create(document);

ParameterTypeExplanationValues
documentjsonCreate a documentvar dataString = '{ "name": "John", "last_name": "Doe" }'
  • Get document by Id:

strapi.services.astra.getById(documentId);

ParameterTypeExplanationValues
documentIdstringGet document by documentIdvar dId = "your_document_id"
  • Get document by Path:

strapi.services.astra.getByPath();

  • Search Collection:

strapi.services.astra.searchCollection(query, pagesize);

ParameterTypeExplanationValues
querystringSearch collection via queryvar query = {"name": { "$eq": "John" }}
pagesizeintNumber of documents to fetchint page_size = 3