I. Databases supported by waterline
Second, waterline can use the same statement to operate different databases, the secret lies in different adapters, in the configuration, you need to set two aspects of the content, one is the specific use of which adapters, and the second is to establish a database connection, the use of which adapter. Here is a sample configuration using the MySQL adapter
Third, when defining the data model table, here is the configuration sample
Note the points:
1. Currently supported data types are///////// string
text
integer
float
date
time
datetime
boolean
binary
array
json
, this range is more than the type range of JavaScript Big.
2. If no primary key is defined, then waterline will create a primary key named ID for you by default, type is integer self-growth
3.waterline automatically create a table when you add Createdat, updatedat two fields, type DateTime, respectively, in the Insert and Update Operations Update field represents the record creation time and update time
4、如果不想自动创建列createdAt、updatedAt,那么请设置
autoCreatedAt,autoUpdatedAt的值为false,如果未设置,insert或update时又未传这两时间,会报错
Iv. Common Query methods
Waterline has the following query methods
Example: In Name=walter and state=new Mexico Records, Query id>100 and age=21, results are limited to 100, and returned in ascending name order
User.find ({name: ' Walter ', State: ' New Mexico '}) . Where ({id: {' > ': +}}). where ({age:21})
. exec (Err, users) {//do stuff here});
Database orm---waterline under nodejs