strapi-hook-astra

0.1.6 • Public • Published

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);

Parameter Type Explanation Values
document json Create a document var dataString = '{ "name": "John", "last_name": "Doe" }'
  • Get document by Id:

strapi.services.astra.getById(documentId);

Parameter Type Explanation Values
documentId string Get document by documentId var dId = "your_document_id"
  • Get document by Path:

strapi.services.astra.getByPath();

  • Search Collection:

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

Parameter Type Explanation Values
query string Search collection via query var query = {"name": { "$eq": "John" }}
pagesize int Number of documents to fetch int page_size = 3

Readme

Keywords

Package Sidebar

Install

npm i strapi-hook-astra

Weekly Downloads

0

Version

0.1.6

License

MIT

Unpacked Size

5.45 kB

Total Files

3

Last publish

Collaborators

  • dpatel257