1.0.2 • Published 3 years ago

pg-nosql v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

pg-nosql

Installation:

$ npm install pg-nosql

Example:

const pgnosql = require('pg-nosql');
const knex = pgnosql(require('knex'));

async function main() {
    const db = knex({
        client: 'pg',
        connection: {
            user: 'postgres',
            host: 'localhost',
            database: 'dbname',
            password: 'root',
            port: 5432,
        }
    });

    if (!await db.schema.hasTable('tablename')) {
        await db.schema.createTable('tablename', table => {
            table.uuid('id').primary();
            table.jsonb('data');
        });
    }

    // Insert
    db.from('tablename').add({
        id: 0,
        text: 'hello'
    }).then((result) => {
        console.log(result);
    })

    // Find and update
    test.find('id', 0).revise({
        id: 1,
        text: 'Goodbye',
    }).then((result) => {
        console.log(result);
    })
}

main();
1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago