https://github.com/mage/mage-vaulthelper-couchbase
Couchbase vault backend helper
https://github.com/mage/mage-vaulthelper-couchbase
Last synced: about 10 hours ago
JSON representation
Couchbase vault backend helper
- Host: GitHub
- URL: https://github.com/mage/mage-vaulthelper-couchbase
- Owner: mage
- Created: 2017-06-16T09:36:30.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-01T06:12:34.000Z (almost 9 years ago)
- Last Synced: 2026-05-09T09:55:03.290Z (about 1 month ago)
- Language: TypeScript
- Size: 15.6 KB
- Stars: 0
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
mage-vaulthelper-couchbase
==========================
Accessing vault backends directly is generally considered
to be tedious in MAGE. This will help you by creating
object instances to access Couchbase directly, so that you may
do N1QL and view query calls.
It will also allow you to define how many N1QL query calls
should run at once, and how many should be queued.
Installation
------------
```shell
npm install --save mage-vaulthelper-couchbase
```
Usage
------
**Examples are written in TypeScript, but this library can also be used in pure JavaScript**
First, you will need to create a helper instance somewhere.
> ./lib/vaults/index.ts
```typescript
import * as couchbase from 'mage-vaulthelper-couchbase'
export const volatileVault = new couchbase.Helper('volatileVault')
export const userVault = new couchbase.Helper('userVault')
export const gameVault = new couchbase.Helper('gameVault')
```
You will probably want to add all your other vault helpers
in here, if you have any.
Then, to access from your modules:
> ./lib/modules/players/index.ts
```typescript
import * as mage from 'mage'
import {
userVault
} from '../../vaults'
exports.list = async function (state: mage.core.IState) {
const results = await userVault.query('select 1') // or another query
mage.logger.debug.data({
results
}).log('got results')
return results
}
```
Acknowledgements
----------------
@AlmirKadric for writing the initial version of this helper.
License
-------
MIT