MySQL adapter for the Sails framework and Waterline ORM. Allows you to use MySQL via your models to store and retrieve data. Also provides a query()
method for a direct interface to execute raw SQL commands.
1 - Install sails-mysql
from NPM.
# In your app:
$ npm install sails-mysql
2 - Create an adapters
folder in your api
folder
3 - Clone https://github.com/PatronizeNG/sails-mysql-gcp.git
into the adapters
folder
4 - Remove Git with rm -rf .git
4 - Replace your datastore config with this:
default: {
adapter: "sails-mysql-gcp",
socketPath: "/cloudsql/<CLOUD_SQL_CONNECTION_NAME>",
user: "<USER>",
password: "<PASSWORD>",
database: "<DATABASE_NAME>",
},
5 - Your app.yaml should look like this:
runtime: nodejs
env: flex
service: sails-app
beta_settings:
# The connection name of your instance, available by using
# 'gcloud beta sql instances describe [INSTANCE_NAME]' or from
# the Instance details page in the Google Cloud Platform Console.
cloud_sql_instances: YOUR_INSTANCE_CONNECTION_NAME
You are good to go