Hi, I am very new to sails. can anyone help me with understanding how & where to pass sql query for mysql database
up vote
-1
down vote
favorite
I am very new to sails. can anyone help me with understanding how & where to pass sql query for mysql database
sails.js
New contributor
add a comment |
up vote
-1
down vote
favorite
I am very new to sails. can anyone help me with understanding how & where to pass sql query for mysql database
sails.js
New contributor
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I am very new to sails. can anyone help me with understanding how & where to pass sql query for mysql database
sails.js
New contributor
I am very new to sails. can anyone help me with understanding how & where to pass sql query for mysql database
sails.js
sails.js
New contributor
New contributor
New contributor
asked yesterday
Krishna
4
4
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
There's a few things you need to do:
1) Install the adapter npm install sails-mysql --save
2) Set up the connection. In the file config/datastores.js
, there is an object called default
. This is where you configure your local database. There is a commented out example of how it should look: adapter: 'sails-mysql', url 'mysql://user:password@host:port/database'
When you're ready to set up your production db, do the same in config/env/production.js
under datastores.default
3) Set up your models: https://sailsjs.com/documentation/concepts/models-and-orm/models
An easy way to get started is using sails generate model <ModelName>
in the cli.
4) Next you have a choice: either set up your tables manually in mysql (using mysql workbench or similar) or you can take advantage of sails auto-migrations to set them up automatically. To do this, make sure that in config/models.js
you have migrate: 'alter'
. Then the first time you lift use sails lift --drop
5) You should now be able to make queries from anywhere in the back end with calls like var newRecord = async <ModelName>.create(...}).fetch()
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
There's a few things you need to do:
1) Install the adapter npm install sails-mysql --save
2) Set up the connection. In the file config/datastores.js
, there is an object called default
. This is where you configure your local database. There is a commented out example of how it should look: adapter: 'sails-mysql', url 'mysql://user:password@host:port/database'
When you're ready to set up your production db, do the same in config/env/production.js
under datastores.default
3) Set up your models: https://sailsjs.com/documentation/concepts/models-and-orm/models
An easy way to get started is using sails generate model <ModelName>
in the cli.
4) Next you have a choice: either set up your tables manually in mysql (using mysql workbench or similar) or you can take advantage of sails auto-migrations to set them up automatically. To do this, make sure that in config/models.js
you have migrate: 'alter'
. Then the first time you lift use sails lift --drop
5) You should now be able to make queries from anywhere in the back end with calls like var newRecord = async <ModelName>.create(...}).fetch()
add a comment |
up vote
0
down vote
There's a few things you need to do:
1) Install the adapter npm install sails-mysql --save
2) Set up the connection. In the file config/datastores.js
, there is an object called default
. This is where you configure your local database. There is a commented out example of how it should look: adapter: 'sails-mysql', url 'mysql://user:password@host:port/database'
When you're ready to set up your production db, do the same in config/env/production.js
under datastores.default
3) Set up your models: https://sailsjs.com/documentation/concepts/models-and-orm/models
An easy way to get started is using sails generate model <ModelName>
in the cli.
4) Next you have a choice: either set up your tables manually in mysql (using mysql workbench or similar) or you can take advantage of sails auto-migrations to set them up automatically. To do this, make sure that in config/models.js
you have migrate: 'alter'
. Then the first time you lift use sails lift --drop
5) You should now be able to make queries from anywhere in the back end with calls like var newRecord = async <ModelName>.create(...}).fetch()
add a comment |
up vote
0
down vote
up vote
0
down vote
There's a few things you need to do:
1) Install the adapter npm install sails-mysql --save
2) Set up the connection. In the file config/datastores.js
, there is an object called default
. This is where you configure your local database. There is a commented out example of how it should look: adapter: 'sails-mysql', url 'mysql://user:password@host:port/database'
When you're ready to set up your production db, do the same in config/env/production.js
under datastores.default
3) Set up your models: https://sailsjs.com/documentation/concepts/models-and-orm/models
An easy way to get started is using sails generate model <ModelName>
in the cli.
4) Next you have a choice: either set up your tables manually in mysql (using mysql workbench or similar) or you can take advantage of sails auto-migrations to set them up automatically. To do this, make sure that in config/models.js
you have migrate: 'alter'
. Then the first time you lift use sails lift --drop
5) You should now be able to make queries from anywhere in the back end with calls like var newRecord = async <ModelName>.create(...}).fetch()
There's a few things you need to do:
1) Install the adapter npm install sails-mysql --save
2) Set up the connection. In the file config/datastores.js
, there is an object called default
. This is where you configure your local database. There is a commented out example of how it should look: adapter: 'sails-mysql', url 'mysql://user:password@host:port/database'
When you're ready to set up your production db, do the same in config/env/production.js
under datastores.default
3) Set up your models: https://sailsjs.com/documentation/concepts/models-and-orm/models
An easy way to get started is using sails generate model <ModelName>
in the cli.
4) Next you have a choice: either set up your tables manually in mysql (using mysql workbench or similar) or you can take advantage of sails auto-migrations to set them up automatically. To do this, make sure that in config/models.js
you have migrate: 'alter'
. Then the first time you lift use sails lift --drop
5) You should now be able to make queries from anywhere in the back end with calls like var newRecord = async <ModelName>.create(...}).fetch()
answered yesterday
streleck
23019
23019
add a comment |
add a comment |
Krishna is a new contributor. Be nice, and check out our Code of Conduct.
Krishna is a new contributor. Be nice, and check out our Code of Conduct.
Krishna is a new contributor. Be nice, and check out our Code of Conduct.
Krishna is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53224431%2fhi-i-am-very-new-to-sails-can-anyone-help-me-with-understanding-how-where-to%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password