@zcatalyst/nosql
v0.0.3
Published
JavaScript SDK for Catalyst NoSQL - Non-Relational Database Management
Maintainers
Readme
@zcatalyst/nosql
JavaScript SDK for Catalyst NoSQL - Non-Relational Database Management
Overview
The @zcatalyst/nosql package provides JavaScript/TypeScript methods to interact with Catalyst NoSQL tables and items. It also exports item, marshalling, unmarshalling, set, byte, and enum helpers. Runs in Node.js (server-side) environments only.
Prerequisites
- A Catalyst project set up
- NoSQL tables created in your project
- Understanding of NoSQL components and concepts
Installation
To install this package, simply type add or install @zcatalyst/nosql using your favorite package manager:
npm install @zcatalyst/nosqlyarn add @zcatalyst/nosqlpnpm add @zcatalyst/nosql
Getting Started
Import
The Catalyst SDK is modularized by Components.
To send a request, you only need to import the NoSQL:
// ES5 example
const { NoSQL } = require('@zcatalyst/nosql');// ES6+ example
import { NoSQL, NoSQLItem } from '@zcatalyst/nosql';Usage
To send a request, you:
- Create a NoSQL Instance.
- Call the NoSQL operation with input parameters.
const nosql = new NoSQL();
const item = new NoSQLItem();
item.addString('fruit', 'mango')
// Add a map
.addMap('properties', {
color: 'yellow'
});
const table = await nosql.getTable('124567890');Async/await
We recommend using await operator to wait for the promise returned by send operation as follows:
try {
const data = await table.insertItems({
item: NoSQLItem.from({
fruitName: 'Banana',
fruitProperties: {
fruitColor: 'Yellow',
fruitType: 'Berries'
}
}),
return: NoSQLReturnValue.NEW
});
// process data.
} catch (error) {
// error handling.
} finally {
// finally.
}Error Handling
try {
const data = await table.insertItems({
item: NoSQLItem.from({
fruitName: 'Banana',
fruitProperties: {
fruitColor: 'Yellow',
fruitType: 'Berries'
}
}),
return: NoSQLReturnValue.NEW
});
// process data.
} catch (error) {
const message = error.message;
const status = error.statusCode;
console.log({ message, status });
}Resources
Contributing
See CONTRIBUTING for more information on how to get started.
License
This SDK is distributed under the Apache License 2.0. See LICENSE file for more information.
