0.0.25 • Published 7 years ago
snake-orm v0.0.25
snake-orm
Support
Sqlite
,Mysql
More Info Please Look the Doc
Install
$ npm install snake-orm -S
# And one of the following:
$ npm install --save mysql2
$ npm install --save sqlite3
Easy use like below:
await User.joins('wallet').where({username: 'zhangsan'}).where('wallets.amount > ?', 100).limit(10).offset(3)
Usage
let SnackeOrm = require('snake-orm')
SnakeOrm.getOrCreateSnakeOrmProxy(database, username, password, {
dialect: ['mysql'|'sqlite3'],
host: 'localhost',
logger: true
})
# Create Model
const { SnakeModel } = SnackeOrm
class User extends SnakeModel {
# default SnakeOrmProxy database
#static get database () {
# return 'database_test'
#}
# default class name plural
# static get table () {
# return 'users'
# }
constructor () {
super(...arguments)
}
}
module.exports = User
Methods
Class
Methods
- find (valueOfPrimaryKey) -> it's
[Bomb Method]
- findBy (options)
- where (options, ...args)
- not (options)
- select (fields)
- order (options)
- group (fields)
- having (options, ...args)
- limit (limit)
- offset (offset)
- paginate (page = 1, perPage = 20)
- count ()
- sum (field)
- avg (field)
- min (field)
- max (field)
- withTransaction(blockAfn)
- findOrCreateBy (object, blockAfn)
- create(object, blockAfn)
- updateAll(object)
- destroyAll()
- destroyAllTableData()
Instance
Methods- update(object, blockAfn)
- save()
- increment(field, value)
- decrement(field, value)
- destroy()
Log Sql
please set
debug
orlogger
->true
0.0.25
7 years ago
0.0.24
7 years ago
0.0.23
7 years ago
0.0.22
7 years ago
0.0.21
7 years ago
0.0.20
7 years ago
0.0.19
7 years ago
0.0.18
7 years ago
0.0.17
7 years ago
0.0.16
7 years ago
0.0.15
7 years ago
0.0.14
7 years ago
0.0.13
7 years ago
0.0.12
7 years ago
0.0.11
7 years ago
0.0.10
7 years ago
0.0.9
7 years ago
0.0.8
7 years ago
0.0.7
7 years ago
0.0.6
7 years ago
0.0.5
7 years ago
0.0.3
7 years ago
0.0.2
7 years ago
0.0.1
7 years ago