Skip to content

shwetasrivastava/Ohana

Repository files navigation

Ohana - SAP HANA ORM for Node.js

NOTE: Ohana is a work in progress and this README will update as progress is made

Version Total Downloads License

How to use it?

  • Install from npm
    npm install ohana-node-orm
  • Setup the connection
const {connection} = require('ohana-node-orm');

const connectionParams = {
    host: process.env.SAP_HDB_URL,
    port: process.env.SAP_HDB_PORT,
    user: process.env.SAP_HDB_UID,
    password: process.env.SAP_HDB_PASSWORD,
    dbname: process.env.SAP_HDB_DBNAME
}

connection.connect(connectionParams)
.then((success) => {
    console.log('Connected');
})
.catch((error) => {
    console.log('Error', error);
})
  • Create a Model
const {ohana} = require('ohana-node-orm');

const user = new ohana('users'); // new ohana('table_name');

module.exports = user;
  • Use model in your controller
const users = await user.find();

Supported operations

  • find(column_name, conditions)
  • findOne(column_name,conditions)
  • insert(data)
  • destroy(conditions)
  • batchInsert(data)
  • update(conditions, values)
  • updateOrCreate(conditions, values)
  • avg(column_name, conditions)
  • count(column_name, conditions)
  • destroy(conditions)
  • findOneOrCreate(conditions, values)
  • max(column_name, conditions)
  • min(column_name, conditions)
  • raw(statement)
  • sum(column_name, conditions)

For further details on how to use the above functions ; please see the details on :-

https://shwetasrivastava.github.io/Ohana/