node. JS Framework Strongloop Learning notes (i)
I am using node. js to do the phone backstage, find the framework found Strongloop quite suitable, but found no Chinese tutorial, so in their own study, do a note, to facilitate other people like me reference (my english level is very poor, only a little try to do, and record down, if you find the problem, please inform me good correction, Thanks, man. )。 All operations are done under Centos7-x64,node.js 0.12.2.
- Nodejs Frame Strongloop Learning Note one
- Installing Strongloop
- Create a project
- Installing Database Drivers
- Configure Database connections
Installing Strongloop
NPM install-g Strongloop
Create a project
- In the terminal into the working directory (for example: My job is/home/work/strongloop, ie cd/home/work/strongloop), input SLC loopback
- Then prompt? What ' s the name of your application? (Strongloop) , which lets you enter the project name, the default directory name is the project (for example: I enter study)
- Then prompt? Enter name of the directory to contain the project: (study) , which allows you to enter the catalog name of the item, the project name that you just entered is the directory name (for example: if you add a car here directly)
- Next Strongloop will create the directory for you and create the default project file and the default node. js module, after which the project is finished.
attached : You can also create a new directory directly under the working directory, the directory name on the project name, and then enter the SLC loopback; directly enter, the default project file and the default node. JS module are created, and the project is finished after completion.
Installing Database Drivers
Execute in the project directory, NPM install Loopback-connector-mysql–save, or at the end of the "dependencies" in the project directory's Package.json file ,"loopback-connector-mysql": "^*"
, and then execute NPM Install
The following databases are supported:
MongoDB npm Install Loopback-connector-mongodb–save
mysql npm install Loopback-connector-mysql–save
Oracle NPM Install Loopback-connector-oracle–save
PostgreSQL npm Install Loopback-connector-postgresql–save
rest npm Install Loopback-connector-rest–save
SQL Server npm install Loopback-connector-mssql–save
Configure Database connections
First, the command line mode
- Executed under the project directory
slc loopback:datasource
;
[?] Enter the data-source name:
Enter the database connection configuration name;
[?] Select the connector for mysqlDS: (Use arrow keys)
other
In-memory db (supported by StrongLoop)
MySQL (supported by StrongLoop)
PostgreSQL (supported by StrongLoop)
Oracle (supported by StrongLoop)
Microsoft SQL (supported by StrongLoop)
MongoDB (supported by StrongLoop)
(Move up and down to reveal more choices)
Select your database type
- Edit the project directory/server/datasources.json file, in the "connector": "MySQL" (Here is the database type you selected) after adding host, port, database, username and password and other items, Save, set up.
Second, the Web interface mode
Execute in project directory, SLC Arc; Open the Strongloop Web management interface in the browser
Click on register below to enter Strongloop register a mailbox
Strongloop will send you a confirmation letter to fill in the mailbox, through the inside of the connection to complete the registration; then log in with your registered email and password to the Strongloop page management interface, click Composer
In the lower left corner select the type of database you want to connect to, I am here MySQL; and configure a name for the database connection, as I call MySQL here; then fill in the following database connection information, point to save datasource saving configuration
Click on the bottom of the test connection testing configuration is correct, if correct will be prompted on the Web page success
Come here today, rest and rest!
node. JS Framework Strongloop Learning notes (i)