Created
January 10, 2014 04:21
-
-
Save cgmartin/8346950 to your computer and use it in GitHub Desktop.
Separate mysql db adapter test with Sails.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| adapter: 'mysqlDb1', | |
| attributes: { | |
| name: 'string' | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| adapter: 'mysqlDb2', | |
| attributes: { | |
| name: 'string' | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports.adapters = { | |
| 'default': 'disk', | |
| disk: { | |
| module: 'sails-disk' | |
| }, | |
| mysqlDb1: { | |
| module: 'sails-mysql', | |
| host: 'localhost', | |
| user: 'root', | |
| password: '', | |
| database: 'sailsDb1', | |
| pool: false | |
| }, | |
| mysqlDb2: { | |
| module: 'sails-mysql', | |
| host: 'localhost', | |
| user: 'root', | |
| password: '', | |
| database: 'sailsDb2', | |
| pool: false | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports.bootstrap = function (cb) { | |
| function createMysqlTestData(done) { | |
| async.parallel([ | |
| function(done) { | |
| var modelA = [{ "name": "testA" }]; | |
| ModelA.count().exec(function(err, count) { | |
| if (err) return done(err); | |
| if (count > 0) return done(); | |
| ModelA.create(modelA).exec(done); | |
| }); | |
| }, | |
| function(done) { | |
| var modelB = [{ "name": "testB" }]; | |
| ModelB.count().exec(function(err, count) { | |
| if (err) return done(err); | |
| if (count > 0) return done(); | |
| ModelB.create(modelB).exec(done); | |
| }); | |
| } | |
| ], done); | |
| } | |
| createMysqlTestData(cb); | |
| }; |
Is there a way to create FK in the different DB using the mySql-adapter?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there is any particular way to switch amongs different Db's prgramatically?
Im planning to give Separate Db's for each of my Signed up users.