mirror of
https://github.com/HeyPuter/puter.git
synced 2026-08-25 15:37:12 +00:00
dev(extensions): [+] data
The data extension adds convenient access to the database and kvstore
via it's 'db' and 'kv' exports.
Example usage:
const { db, kv } = extensions.import('data');
await kv.set('some-key', 'some-value');
await db.write('INSERT INTO something (a, b) VALUES (1, 2)');
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
//@extension priority -10000
|
||||
|
||||
const { DB_WRITE } = extension.import('core').database;
|
||||
const svc_database = extension.import('service:database');
|
||||
const svc_kvstore = extension.import('service:puter-kvstore');
|
||||
|
||||
extension.exports = {
|
||||
db: svc_database.get(DB_WRITE, 'extensions'),
|
||||
kv: svc_kvstore.as('puter-kvstore'),
|
||||
};
|
||||
@@ -105,6 +105,8 @@ const install = async ({ context, services, app, useapi, modapi }) => {
|
||||
def('web', require('./util/expressutil'));
|
||||
def('core.validation', require('@heyputer/backend-core-0').validation);
|
||||
|
||||
def('core.database', require('./services/database/consts.js'));
|
||||
|
||||
// Extension compatibility
|
||||
const runtimeModule = new RuntimeModule({ name: 'core' });
|
||||
context.get('runtime-modules').register(runtimeModule);
|
||||
|
||||
Reference in New Issue
Block a user