@withkoji/database
v1.0.28
Published
SDK for communicating between a Koji template and its in-built database service.
Downloads
7
Keywords
Readme
Koji Database (deprecated)
SDK for communicating between a Koji template and its in-built database service.
Overview
The @withkoji/database package enables you to implement a Koji database for the backend of your template. A Koji database is a key-value store that is included with each project on Koji.
[DEPRECATED] This package is deprecated and is included only for backwards compatibility. For new templates, use @withkoji/core.
Installation
Install the package in the backend service of your Koji project.
npm install --save @withkoji/database
NOTE: To support instant remixes of your template, you must also install the @withkoji/vcc package and implement the VccMiddleware
on your backend server. This middleware maintains the environment variables for instant remixes, ensuring that database access is restricted to the correct remix version.
Basic use
Import and instantiate the database SDK in the backend service.
import Database from '@withkoji/Database';
const database = new Database({
projectId: res.locals.KOJI_PROJECT_ID,
projectToken: res.locals.KOJI_PROJECT_TOKEN,
});
Set database entries in the database using the SDK.
const isAdded = await database.set('myCollection', 'myKey', {'myValue':1});
Get database entries from the database using the SDK.
const myEntry = await database.get('myCollection','myKey');
Related resources
Contributions and questions
See the contributions page on the developer site for info on how to make contributions to Koji repositories and developer documentation.
For any questions, reach out to the developer community or the @Koji Team
on our Discord server.