Neocon Propaganda Machine
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

teo-db-adapter-waterline

1.0.1 • Public • Published

teo-db-adapter-waterline

Teo.JS Waterline DB Adapter.

Usage example

const WaterlineAdapter = require("teo-db-adapter-waterline");
 
let adapterInstance = new WaterlineAdapter({
    waterlineAdapters: {
        // adapters should be installed as packages via npm
        "default": require('sails-disk'),
        disk: require('sails-disk'),
        mysql: require('sails-mysql')
    },
    connections: {
        myLocalDisk: {
            adapter: "disk"
        },
        myLocalMySql: {
            adapter: "mysql",
            host: "localhost",
            database: "foobar"
        }
    };
});
 
adapterInstance.addModel({
    identity: 'user',
    connection: 'myLocalDisk',
 
    attributes: {
        first_name: 'string',
        last_name: 'string'
    }
});
 
yield* adapterInstance.connect();       // connects ORM
yield* adapterInstance.disconnect();    // disconnects ORM

API

addModel(identity, modelObject)

Adds model to the registry. The identity argument is not necessary. You can pass identity inside model object. Otherwise, identity will be the first key of the passed model object.

connect() [generator function]

Connects ORM. All models should be loaded before the connection to DB.

disconnect() [generator function]

Disconnects ORM.

isConnected()

Returns boolean to detect if connection is set.

install

npm i teo-db-adapter-waterline

Downloadsweekly downloads

0

version

1.0.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability