Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikesparr/loopback-example-users-to-mysql
Example how to migrate the built-in User model to use MySQL instead of Memory db
https://github.com/mikesparr/loopback-example-users-to-mysql
Last synced: about 6 hours ago
JSON representation
Example how to migrate the built-in User model to use MySQL instead of Memory db
- Host: GitHub
- URL: https://github.com/mikesparr/loopback-example-users-to-mysql
- Owner: mikesparr
- Created: 2015-06-10T14:56:51.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-06-10T15:32:33.000Z (over 9 years ago)
- Last Synced: 2024-12-21T19:02:30.915Z (20 days ago)
- Language: JavaScript
- Size: 117 KB
- Stars: 14
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Loopback Example (MySQL)
The project is generated by [LoopBack](http://loopback.io). I read about
people wanting to use their own database for the built-in user model and
decided to see how easy it would be to accomplish. I followed the instructions
in https://github.com/strongloop/loopback-example-mysql and built the example
from scratch, and then edited the User model.## How To Change Built-In User Model To MySQL Database
* make sure you have the new MySQL datasource configured from tutorial
* edit the `/server/model-config.json` file changing built-in models to your new DS
* create the `/server/bin/automigrate.js` file (should be built from tutorial) and add `automigrate()` functions for each built-in Model
* run `> node server/bin/automigrate.js` and you should see the following:~~~
Your-Computer:loopback-example-mysql your-username$ node server/bin/automigrate.js
User model migrated
ACL model migrated
AccessToken model migrated
Record created: { email: '[email protected]',
createdAt: Wed Jun 10 2015 08:29:10 GMT-0600 (MDT),
lastModifiedAt: Wed Jun 10 2015 08:29:10 GMT-0600 (MDT),
id: 2 }
Record created: { email: '[email protected]',
createdAt: Wed Jun 10 2015 08:29:10 GMT-0600 (MDT),
lastModifiedAt: Wed Jun 10 2015 08:29:10 GMT-0600 (MDT),
id: 1 }
done
Role model migrated
RoleMapping model migrated
~~~If you check your database, you should now have the tables created and when you use the
built-in `localhost:3000/explorer` app after starting the app, you can create users and
they will appear in your database.Kudos to the team at StrongLoop for building a nice framework and auto-scaffolding. I look
forward to learning more and hopefully contributing as time permits.