0.0.25 • Published 8 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 sqlite3Easy 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 = UserMethods
ClassMethods
- 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()
InstanceMethods- update(object, blockAfn)
- save()
- increment(field, value)
- decrement(field, value)
- destroy()
Log Sql
please set
debugorlogger->true
0.0.25
8 years ago
0.0.24
8 years ago
0.0.23
8 years ago
0.0.22
8 years ago
0.0.21
8 years ago
0.0.20
8 years ago
0.0.19
8 years ago
0.0.18
8 years ago
0.0.17
8 years ago
0.0.16
8 years ago
0.0.15
8 years ago
0.0.14
8 years ago
0.0.13
8 years ago
0.0.12
8 years ago
0.0.11
8 years ago
0.0.10
8 years ago
0.0.9
8 years ago
0.0.8
8 years ago
0.0.7
8 years ago
0.0.6
8 years ago
0.0.5
8 years ago
0.0.3
8 years ago
0.0.2
8 years ago
0.0.1
8 years ago