1.1.17 • Published 5 years ago

@zctod/node-rds v1.1.17

Weekly downloads
-
License
MIT
Repository
github
Last release
5 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

5 years ago

1.1.16

5 years ago

1.1.15

5 years ago

1.1.14

5 years ago

1.1.13

5 years ago

1.1.12

5 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago