SailsJS Schema Name Issue - sails.js

I am trying to connect my SailsJS app to a postgres db that has another schema aside from 'public'
The schema name of the postgres DB that I am connecting to is 'sales'
Where am I am going wrong?
Thank you!
connection: 'postgres',
tableName: 'user__c',
meta: {
schemaName: 'sales'
},
attributes: {
name: {
type: 'string'
},
picture_url: {
type: 'string'
}
}

It's been so long but still, this is still an issue with waterline-sequel (0.5.0) in the latest version of Sails (0.11.x), and it has not been resolved so far.
The meta.schemaName is present in the code, but it's currently for the decorative purposes (orphaned). :)

Based on what you have written, nothing is wrong with the form and structure of your model definition.
Please include more information if you continue to receive an error.

Related

Problems connecting to mysql database using mysql1 package on flutter web

im tying to connect to my mysql database using mysql1 package, i've tried sqljocky as well, but both of them dont work.
I get error Error: Unsupported operation: RawSocket constructor
my code is exactly like in example, heres my code, maybe youll see what im doing wrong.
import 'package:mysql1/mysql1.dart';
class Database {
static var s = ConnectionSettings(
user: "user",
password: "password",
host: "host",
port: 3306,
db: "db",
);
static Future<MySqlConnection> connect() async{
return await MySqlConnection.connect(s);
}}
Unfortunately, mysql1 does not support web: https://github.com/adamlofts/mysql1_dart#flutter-web
I think in general, a web application would be better off using a REST-API approach, since you don't want to expose your SQL credentials in the Frontend.

SailsJS 1.0 + SQL Server adapter compatibility?

I am trying to connect sails 1.0 to SQL Server, but I've been out of luck so far. There doesn't seem to be anything publicly available.
I did found someone on GitHub that did try to add support, although when i try to use their branch it didn't work out too well.
Got this error when I try to use the model.findOne() method.
name: 'RequestError',
message: 'Incorrect syntax near \'BY\'.',
code: 'EREQUEST',
number: 102,
lineNumber: 1,
state: 1,
class: 15,
serverName: 'sql1b',
procName: '',
precedingErrors: [] }
Was anyone else more lucky in getting sails 1.0 to work with a SQL Server database?
Yes, you can try sails-sqlserver-sailsv1. But don't follow the guide in the npm site, probably a copy/paste error on how to install the package. use:
npm install sails-sqlserver-sailsv1 --save
And in the datastore configuration on sails make sure to use the correct adapter name:
default: {
adapter: 'sails-sqlserver-sailsv1',
user: 'cnect',
password: 'pass',
host: 'abc123.database.windows.net' // azure database
database: 'mydb',
options: {
encrypt: true // use this for Azure databases
}
}
I hope it helps you.
You may want to change from waterline - default SailS ORM - to Sequelize + Tedious. Waterline is very dependent on the work of the opensource community, and thus SQL Server is not (and I don't think it will ever be) supported.

Sails.js - Authorisation issues with remote MongoDB on mLab but working fine locally

Recently, I took over a Sails.js application created for our company by a small team of web developers. They provided me with the source and a database dump. Now, my task is to get it up and running on Heroku. While everything is working okay when I run the app locally, with the remote connection there is an error on startup that says:
MongoError: not authorized on heroku_gbntc8sf to execute command { createIndexes: "agendaJobs", indexes: [ { key: { name: 1, priority: -1, lockedAt: 1, nextRunAt: 1, disabled: 1 }, name: "findAndLockNextJobIndex1" }, { key: { name: 1, lockedAt: 1, priority: -1, nextRunAt: 1, disabled: 1 }, name: "findAndLockNextJobIndex2" } ] }
at Function.MongoError.create ([ROOT_DIR]/node_modules/mongodb-core/lib/error.js:31:11)
at [ROOT_DIR]/node_modules/mongodb-core/lib/topologies/server.js:793:66
at Callbacks.emit ([ROOT_DIR]/node_modules/mongodb-core/lib/topologies/server.js:94:3)
at null.messageHandler ([ROOT_DIR]/node_modules/mongodb-core/lib/topologies/server.js:235:23)
at Socket.<anonymous> ([ROOT_DIR]/node_modules/mongodb-core/lib/connection/connection.js:259:22)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at Socket.Readable.push (_stream_readable.js:110:10)
at TCP.onread (net.js:523:20)
Here's a quick checklist of what I've done already:
checked the build log on Heroku - no errors or warnings;
set up mLab Heroku add-on, exported the database, done some manual checks from the mLab dashboard - everything looks okay;
logged in to the database remotely from the mongo command and a mongo:// URL, ran a few simple queries, and obtained information on the database user privileges;
created an identical user (with the heroku_gbntc8sf username, same password, same role, etc.) in the local database.
Here's what the connection configuration looks like:
// config/connections.js
module.exports.connections = {
mongodb: {
adapter: 'sails-mongo',
user: 'heroku_gbntc8sf',
password: [HIDDEN],
host: 'ds159387.mlab.com',
port: 59387,
database: 'heroku_gbntc8sf'
},
// ...
}
// config/env/development.js
module.exports = {
models: {
connection: 'mongodb'
},
// ...
}
// config/env/production.js
module.exports = {
models: {
connection: 'mongodb'
},
// ...
}
At the moment I'm running the server locally, trying to connect to the remote database, to eliminate as many variables as possible. Like I mentioned above, when I set host to '127.0.0.1' and port to 27017, everything works okay. The heroku_gbntc8sf user has basic readWrite permissions in both databases (local and remote). In fact, those two databases are pretty much identical, as far as I know. And yet...
I've read a sizeable chunk of the Sails.js documentation, as well as, the documentation on the sails-mongo adapter. I've searched for similar questions, but I couldn't find anything relevant. I've tried many different things, including a couple of different ways to configure the database connection, but that error is always there.
The reason why I'm posting to StackOverflow is that I cannot rely on the support from the original authors of the app at the moment. Also, I'm new to Sails.js, so I might be doing something wrong without even knowing. I was hoping that I could get away with treating the app as a 'black box' (or like a generic Node application), since my job is only to start the app on Heroku.
I've successfully used mLab in a Sails project recently, but I've used the Mongo URL string format, for example...
mongodbServer: {
adapter: 'sails-mongo',
url : "mongodb://dandanknight:som3P455w0rd#ds044979.mlab.com:44979/databasename"
}
Not sure if it helps, but can't hurt to try! It's also the only way I've successfully got a replicaSet working in Sails incidentally.
It's confusing, but I read the sails-mongo docs as "URL is the way forward, and passing an object is legacy usage" (here)

sails js - error when clean the collections in start up

In my sails application I edit the config/models.js file as follows to clean the database when lifting the application.
migrate: 'drop',
connection: 'mongodb'
But when I try to run the application it displays the following error.
A hook (`orm`) failed to load!
error: Error (E_UNKNOWN) :: Encountered an unexpected error
MongoError: Index with name: _id_ already exists with different options
I am using sails version 0.10.5 ,any kind of help would be appreciated.
same here, when you have an error to the model the orm crashes, at least you have the error, sometimes with mysql you don't even have the error
the issue was, in some of my application's model files I have added following to attributes list.
attributes: {
_id: {
type: 'string',
unique: true
}
}
since I have added unique true to the attribute, it causes an error when I try to clean the collections on start up. more information about this issue can be found on Index already exists with different options error while using createIndex() in latest MongoDB java driver

SAILS-CBES adapter key, what is it?

I had issues correctly configuring my couchbase adapter in sails-js. I am using the sails-cbes adapter. The documentation fails to mention the key to use. For any who might struggle as I did, below is my configuration file:
{
...
//couchbase
cb: {
adapter: 'sails-cbes',
host: 'localhost',
port: 8091,
user: 'user',
pass: 'password',
bucket: {
name: 'bucket',
pass: 'bucketPassword'
}
}
},
...
Assuming that by 'key' you refer to the 'password' fields:
The first password is the one you set up in the dialogue the first time you log in to https://localhost:8091.
The bucket is not being created automatically so you would have to do that manually in couchbase. Then you have the option to set a password for the bucket itself, but the default is just empty string. Elasticsearch indexing is automated as long as you declare the mapping in the model.
The configuration file should be in sails-project/config/connections.js and it should look something like this:
sailsCbes: {
adapter: 'sails-cbes',
cb: { ... },
es: { ... }
}
You can try it out by creating a model within sails that uses this connection.
As for the dependencies, you need to install couchbase and elasticsearch yourself, then from the sails-cbes folder do a sudo npm install and you should be good to go. For test dependencies, run npm install inside the test folder.
Hope this helps
I think you don't understand how sailsjs adapter works.
Please spend some time and read the documentation of sailsjs, specially the connections configuration (adapters)
http://sailsjs.org/#!/documentation/reference/sails.config/sails.config.connections.html