I'm looking at building a small nodeJs app which will query the parse database. (http://parseplatform.org/)
I'm fine connecting to the mongoDB and querying single collections but has anyone figured out how to use the pointers to join collections in a single query
Ideally using mongoose in node but if there is a better solution I'd be happy to try it.
I've done research and found a lot of people asking the same or similar questions but not found an answer to it yet.
That's because you're joining collections, which screams relational data, which noSQL isn't designed around solving. You can use it to a certain extent, but it will only get you so far. If you have relational data, use a relational database.
noSQL (mongo in this case..) is a document data store for storing "unstructured" data.
Some popular (free) relational db options are PostgreSQL or MySQL.
Related
I am trying to access one database collection in a different database. Is it possible in arangodb.
Regards,
Sajeev
No, its not possible.
ArangoDB strictly separates databases, so AQL doesn't know about databases in first place, its concept is below the database layer.
As we also discussed in the github issue we actually don't intend to implement support for this.
Currently I am using the pg module. I know how to query the database
client.query("INSERT INTO users(username, password) values($1, $2)", [username, password]
But I was wondering if there's a separate module that I don't know about or a "good practice" way of doing queries with PostgreSQL on Node. Especially if there is a primary key such as a username. I tried building models such as User.js but in the models I am still hard coding the query.
Thanks
I think a much easier way of doing this is to use something like Sequelize ORM. In a nutshell, Sequelize will allow you to write all of your schemas and queries using JS objects. If you're unfamiliar with it, there are a few great examples here.
Basically, this will abstract a lot of the raw query code from your Node.js module, and allow you to write more syntactic JS to interact with your DB. It also includes promises, which will give you an easier way around the async nature of Node rather than queries nested inside each other.
If what you want is to gain any level of abstraction for your data layer, knex/bookshelf is what you want.
The best part is you can choose which level of abstraction you want.
Want/need to do raw sql queries? knex can do that for you.
Want neat query builder capabilities? knes have that too.
In need of industrial ORM lift? there is bookshelf.
Bonus: knex has a very decent migration tool, which means if you want to manage database schema versions you can do that too! Migration tools are the best way to avoid madness when dealing with real world databases.
Give it a try:
http://knexjs.org/
http://bookshelfjs.org/
Hope it helps you as it helps me!
I'm actually trying to learn new things...
I used SQL for a long time, using MySQL and recently discovered document-oriented databases.
I came across graph-databases & Neo4j and want to try it through NodeJS but I really don't get the point.
Should I use Neo4j coupled with another DB? Like storing my data into MySQL & relationships in Neo4j?
Or may I use Neo4j to store data (like posts)?
Neo4j is often used as the primary database, see https://github.com/thingdom/node-neo4j for a node.js driver. Also, depending on your use case, you can use it with MySQL in different scenarios for complex queries that take a long time in MySQL like recommendations and other path queries, see http://docs.neo4j.org/chunked/snapshot/data-modeling-examples.html for some interesting starting examples.
/peter
Can anyone point to me of any examples in which i can use an RDBMS to maintain data but use a NOSQL database to pushout data. My goal is to add/update/delete to the RDBMS but store entities with all of thier related data in the NOSQL database. Then, I would like to push the data out from NOSQL. Does this sound like a bad idea? My goal is to have nodejs present this data in a hierarchal format of all of its related data.
As others have said it sounds like you want to store all youre data in 2 different engines, and I can not see the big idea in that unless we are migrating to a new system.
If you are afraid of the nosql consistency and your data do fit in youre rdbms I can't see the point in using the nosql when you can have node connect to your rdbms and fetch the data stright from that.
have a look at driver for postgresql it is a driver for postgresql. I haven't tried it, but it look's like its fairly developed and tested.
I'm getting more into Node.js and am enjoying it. I'm moving more into web application development.
I have wrapped my head around Node.js and currently using Backbone for the front end. I'm making a few applications that uses Backbone to communicate with the server using a RESTful API. In Node.js, I will be using the Express framework.
I'm reaching a point where I need a simple database on the server. I'm used to PostgreSQL and MySQL with Django, but what I'm needing here is some simple data storage etc. I know about CouchDB, MongoDB and Redis, but I'm just not sure which one to use?
Is any one of them better suited for Node.js? Is any one of them better for beginners, moving from relational databases? I'm just needing some guidance on which to choose, I've come this far, but when it's coming to these sort of databases, I'm just not sure...
Is any one of them better suited for
Node JS?
Better suited especially for node.js probably no, but each of them is better suited for certain scenarios based on your application needs or use cases.
Redis is an advanced key-value store and probably the fastest one among the three NoSQL solutions. Besides basic key data manipulation it supports rich data structures such as lists, sets, hashes or pub/sub functionality which can be really handy, namely in statistics or other real-time madness. It however lacks some sort of querying language.
CouchDB is document oriented store which is very durable, offers MVCC, REST interface, great replication system and map-reduce querying. It can be used for wide area of scenarios and substitute your RDBMS, however if you are used to ad hoc SQL queries then you may have certain problems with it's map-reduce views.
MongoDB is also document oriented store like CouchDB and it supports ad hoc querying besides map-reduce which is probably one of the crucial features why people searching for DRBMS substitution choose MongoDB over the other NoSQL solutions.
Is any one of them better for
beginners, moving from relational
databases?
Since you are coming from the RDBMS world and you are probably used to SQL then, I think, you should go with the Mongodb because, unlike Redis or CouchDB, it supports ad hoc queries and the querying mechanism is similar to SQL. However there may be areas, depending on your application scenarios, where Redis or CouchDB may be better suited to do the job.