1.1.17 • Published 6 years ago

@zctod/node-rds v1.1.17

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

node-rds

sql model

Start to use

npm install @zctod/node-rds

Create a model

test.js

const Model = require('@zctod/node-rds').mysql;
class Test extends Model {

    static table() {
        return 'test';
    }
    
    static config() {
        return {
            host: '127.0.0.1',
            user: 'root',
            password: '',
            database: 'test',
        };
    }
}

const test = new Test();
test.get().then(res => {
  console.log(res);
});

Related other models

class User extends Model {

}

class Test extends Model {
    
    user() {
        return this.hasOne(new User(), 'id', 'uid');
    }
    users() {
        return this.hasMany(new User(), 'id', 'uid');
    }
}

const test = new Test();
test.with('user').get().then(res => {
  console.log(res);
});

API

first: test.first()
get: test.get(num)
create: test.create(obj)
insert: test.insert(arr)
update: test.update(obj)
delete: test.delete()
where: test.where(field, op, value)
select: test.select(...fields)
orderBy: test.orderBy(field, 'ASC')
limit: test.limit(10, 1)
join: test.leftJoin(tablename, tablename.field, test.field)
leftJoin: test.leftJoin(tablename, tablename.field, test.field)
rightJoin: test.leftJoin(tablename, tablename.field, test.field)

1.1.17

6 years ago

1.1.16

6 years ago

1.1.15

6 years ago

1.1.14

6 years ago

1.1.13

6 years ago

1.1.12

6 years ago

1.1.11

6 years ago

1.1.10

6 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago