I've been working around some ways to use .native() to do a simple aggregation function in sails with mongo.
Already following the steps to install dependencies. (http://sailsjs.org/documentation/reference/waterline-orm/models/native)
But still it returns me this error : .native is not a function
Did I missed something ?
You may be using the wrong adapter. You can check this in your models.js in the connection key. It might be commented out, if it is, it's going to connect to to local disk. Check that in connections.js, the name of your object that has mongodb config is named the same as models.js. eg.
connections.js
mongoServer: {
adapter: 'sails-mongo',
host: 'localhost',
port: 27017,
database: 'dbname'
}
models.js
connection: 'mongoServer'
Related
According to Astronomer docs here:
Despite this, I'm still not quite sure how to structure the JSON in Extras for this. I've tried:
{ uri: mongodb+srv://myuser:mypass#my-cluster.dwxnd.gcp.mongodb.net/mydb?retryWrites=true&w=majority } in the Extras but that doesn't work:
It seems like this should be obvious, yet I am struggling. What's the correct way, using our MongoDB URI from MongoDB Atlas, to create this connection in Airflow?
This setup worked for me in MongoDB Atlas. Extra part is important as it adds mongodb+srv to the final connection URI. Make sure you have provider package installed (http://airflow.apache.org/docs/apache-airflow-providers-mongo/stable/index.html).
Conn Id: mongo_connection
Conn Type: MongoDB
Host: cluster0.mtfak.mongodb.net
Schema: MyDatabaseName
Login: myuser
Password: mypass
Port: empty
Extra: {"srv": true}
This is what I would try:
Conn Type: mongodb+srv (or mongodb)
Host:my-cluster.blahlah.mongodb.net,
Login: <username>, Password: <password>.
Schema: admin (or your authDB)
The JSON object is as simple as this
{ retryWrite:true,
<field>:value,
w:majority
}
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.
I am using both elasticsearch plugins and mongodb plugins in my grails project.
The application.yml file is like:
mongodb:
host: "localhost"
port: 27017
databaseName: "search"
elasticSearch:
client:
mode: local
disableAutoIndex: false
datastoreImpl: mongoDatastore
bulkIndexOnStartup: true
index:
store.type: mmapfs
I commented out the hibernate in build.grdle because I need to use mongodb as your primary datastore.
//compile "org.grails.plugins:hibernate4"
Then the mongodb worked well since I could use
MyDomain.findByXXXXX()
to query the data in my mongodb.
But when I used
def result = MyDomain.search("${query}")
or
def result = elasticSearchService.search("${query}")
and print the result, it showed
[total:0, searchResults:[]]
That seemed the elasticSearch plugins worked but it did not connect to the mongodb.I wonder whether datastoreImpl: mongoDatastore worked or not.
Is there something I am missing? Appreciate your help in advance.
Thank You
I am right now attempting my first Heroku deployment of a SailsJS API. My app uses SailsJS v0.11 andsails-mongo 0.11.2.
I have updated config/connections.js to include the connection information to MongoDB database I have hosted for free at Mongolab.
mongodb: {
adapter: 'sails-mongo',
url: "mongodb://db-user:password123#ds047812.mongolab.com:47812/testing-db"
}
Also updated config/models.js to point to that adapter.
module.exports.models = {
connection: 'mongodb',
migrate: 'safe'
};
This is basically all I have changed from running the code locally, when I deploy to Heroku the app crashes and I get this error...
/home/zacharyhustles/smallChangeAPI/node_modules/connect-mongo/lib/connect-mongo.js:186
throw err;
^
at Socket.emit (events.js:107:17)
2015-07-08T19:37:00.778316+00:00 app[web.1]:
at Socket.<anonymous> (/app/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/connection/connection.js:534:10)
Error: Error connecting to database: failed to connect to [localhost:27017]
How do I get rid of this, and make sure Sails does not try connecting to localhost db?
Ok, the problem was with storing sessions.
My solution was to setup a Redis database to store sessions.
In config/sessions.js make sure everything is commented out except for the method you want for session store.
Mine looked like this:
adapter: 'redis',
host: 'example.redistogo.com',
port: 1111,
db: '/redistogo',
pass: 'XXXXXYYYYYYXYXYXYYX',
This solved my posted problem, hope this helps another person out.
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