Database orm---waterline under nodejs

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.