janiel14 / node-sybase-nu

MIT License
1 stars 0 forks source link

Description

node-sybase-nu

  SyBase ORM for node like Sequelize.js

NPM

npm install node-sybase-nu

Use

const SyBase = require('../db')

module.exports = () => {
  const { STRING, INTEGER, DATE, DECIMAL } = SyBase

  return SyBase.define('WXUser', {
    id: {
      type: INTEGER,
      allowNull: false,
      primaryKey: true,
      autoInc: true
    },
    openid: {
      type: STRING
    },
    headurl: {
      type: STRING
    },
    wxname: {
      type: STRING
    },
    cardno: {
      type: STRING
    },
    phone: {
      type: STRING
    },
    state: {
      type: STRING,
      defaultValue: '00'
    },
    regdate: {
      type: DATE,
      defaultValue: function () {
        return new Date()
      }
    },
  }, {
      tableName: 't_wxuser'
    })
}

  // This is a exemple. Production use require('node_sybase')
  const SyBase = require('../dist/node_sybase')

  module.exports = new SyBase([
    {
      name: 'main',
      host: '10.0.0.141',
      port: 2087,
      dbname: 'web?charset=cp936',
      username: 'username',
      password: '123456',
      logging: true,
      encoding: "utf8"
    }
  ])

  const SyBase = require('./db')
  SyBase.use(__dirname + '/models')

  Sybase.models.WXUser.by(SyBase.DBPools.main)


about detail please See exemple