nav-orm

0.0.1 • Public • Published

###ORM

Currently, only mysql is supported.

npm install nav-orm --save

###Setup

You must set the following environment variables in your app. We recommend creating a .env file and using dotenv

DB_DRIVER=mysql
DB_HOST=localhost
DB_USERNAME=test
DB_PASSWORD=secret
DB_NAME=blah

###Create a Model

chat.js

import { Model } from 'orm'

export default class Chat extends Model {

  /*
  overwrite table name, this function is optional

  static tableName() {
    return 'dashboard_chats'
  }
  */
}

###Using the Model

As long as the plural version of the model is available in the database (you can overwrite this), you can query the database.

import Chat from './chat'

async function getChats {
  let chats = await Chat.all()
  console.log(chats)
}

####Supported methods

.all() - returns everything in the table .where({ fieldName: 'value' }) - returns any matching results .create({ field: 'value'}) - create a new row

Readme

Keywords

none

Package Sidebar

Install

npm i nav-orm

Weekly Downloads

0

Version

0.0.1

License

ISC

Last publish

Collaborators

  • zackify