Is there an equivalent for Codeigniter's implementation of active record in NodeJS somewhere?
I am well aware of the basic mysql connector, however all the security/convenience features that a newbie such as myself relies on to not end up in catastrophe don't appear to be there - it looks like just talking raw SQL to the database driver.
Take a look at Tower project.It is a node based project with very minimal dependencies
Or you can also look at MySQL ActiveRecord Adapter for Node.js
Check JugglingDB - cross-db ORM for nodejs
Related
After seeing this image:
http://2.bp.blogspot.com/_T-uXeKcGTnM/TIdoKBGwk9I/AAAAAAAABcs/CLW3_cRlN78/s1600/tumblr_kxovt0VLZy1qappj8.png
I wonder is exists any tool for translating SQL querys into MongoDB map/reduce query model??
Larger version of the image: http://rickosborne.org/download/SQL-to-MongoDB.pdf
Update to the question asked in Jan 2011:
A couple of sites exist now to convert sql to mongodb.
Convert MySQL Queries to MongoDB Syntax
http://www.querymongo.com/
And
Convert sql to mongodb
http://klaus.dk/sqltomongodb/
The simple anwser? No.
The slightly more complex anwser is some people have had luck translating more complex SQL to Mapreduce functions ...
http://rickosborne.org/blog/index.php/2010/02/08/playing-around-with-mongodb-and-mapreduce-functions/
http://rickosborne.org/blog/index.php/2010/02/19/yes-virginia-thats-automated-sql-to-mongodb-mapreduce/
However, that said ... generally speaking you might as well learn mapreduce properly because if the data is in MongoDB already ... you'll really need to know how to properly query MongoDB to get anything meaningful done!
MongoDB has wonderful and helpful docs http://www.mongodb.org/display/DOCS/Advanced+Queries
As well as an easy to use online tutorial: http://try.mongodb.org/
The simple answer: Yes. Hibernate OGM - JPA for NoSQL.
JPA is Java API for mapping objects to data stores.
It includes JPQL, a query language similar to SQL which adds the OOP concepts. It's not SQL, but you don't want pure SQL - that was designed for the relational paradigm.
Hibernate OGM proposes to simplify the programming model by embracing JPA/Hibernate APIs and semantics to store data in NoSQL stores like JBoss Enterprise Data Grid instead of the traditional RDBMS. (source)
Also see this Hibernate OGM: JPA for NoSQL talk by Hardy Ferentschik
Recently I happened to see this website mongoquery.com, you can try it.
You can use free sql to mongodb converter like: https://rapidapi.com/ariefsam/api/easy-sql-to-mongodb-aggregation/
Just to add to the last comment
re:The simple answer: Yes. Hibernate OGM - JPA for NoSQL.
JPA is Java API for mapping objects to data stores.
It includes JPQL, a query language similar to SQL which adds the OOP concepts. It's not SQL, but you don't want pure SQL - that was designed for the relational paradigm.
There is a company called UnityJDBC that has released a JDBC driver for Mongo that allows you to run SQL queries against mongo in any java application that supports JDBC.
you can download this driver free at
http://www.unityjdbc.com/mongojdbc/mongo_jdbc.php
hope this helps
You can also http://teiid.org which gives full range of SQL based access to MongoDB. You can use SQL through JDBC/ODBC or use REST/ODATA based access to MongoDB. Teiid uses MongoDB's aggregation framework to provide advanced SQL MongoDB query conversation.
I'm playing around with expressjs for a while and now the time has come to connect to a mysql database. Now i'm searching for a way to write and retrieve data from it. Normally i'm creating the database tables with MySQL Workbench. I'm using MySQL because of the ability of using ForeignKeys. Couldn't figure out yet how to do it in other database types...
Currently i'm more used to medoo for PHP. It only connected to a database and gave me the ability to access it in an object oriented way.
Is there a similar module for nodejs out there?
Try knex for a sql-builder library, it's pretty solid and looks sort of similar to medoo (but it uses Promises and is asynchronous).
I am new to Node.js and express. Now I am planning to use database for my application. I am used to with mysql. when I google about using database with node.js I found something weird like any-db node-sql or some kind of weird adapters that I need to use to access my normal mysql database. So which one should I use?
What about using https://www.npmjs.org/package/mysql I guess this is the most commonly used module for MySQL.
Is there any mysql framework for node.js?
I found only https://github.com/felixge/node-mysql but this only allows executing "raw" mysql statements. I am looking for some tool which will provide easier way of manipulating mysql database and data.
Especially I need pagination and joining mechanisms...
I am not looking for a full framework because I am using restify to build RESTapi - just need a module to retrieve/save data to mysql db. So I need only "model" part of MVC ;).
It sounds like you may be looking for an ORM. If that's the case, you can take a look at Sequelize. It will let you define your objects, and then simply 'save' and 'fetch' them, without really having to worry about how its doing it.
You can look at db-mysql module. This module provides api for creating queries. Here is module GitHub page.
I need to use Node.js, but it doesn't have a good ORM for MySQL. So I'm planning on using SQLAlchemy to define my schema. And then use node-mysql to do low-level queries (of course, I wouldn't be able to use SQLAlchemy's query language coz it's in python.)
What do you guys think?
sequelize seems to be the best one...but it doesn't seem that many people are using it. Also, what about migrations? How would I handle that?
node-orm doesn't seem very active either.
Thoughts on this?
Sequelize is pretty good ORM for MySQL and has excellent documentation. You can use node-migrate for migrations.
We are using Sequelize.js in our Node project and I guess it kind of does the job done but there are gotchas. One example is that the MySQL Sequelize query engine does case sensitive string matching on the SQL string that you feed it (this.sql.indexOf('SELECT') == 0). This means it can fail if your SQL happens to be lowercase. SQL keywords are usually case insensitive (although upper case by convention) so the Sequelize implementation seems like a hack.
There is migration support in Sequelize as of version 1.3.0 but I haven't used it and I'm considering rolling my own instead.
I come from a background of having used the Ruby ActiveRecord ORM and in light of this and the gotcha mentioned above I'm hesitant to recommend Sequelize. Unfortunately, I don't know what better alternatives are out there.
UPDATE1: there are other ORMs suggested under "Which ORM should I use for Node.js and MySQL?".
UPDATE2: I've released my Sequelize.js migration code on Github
You can use light-orm and mysql:
https://npmjs.org/package/light-orm - ORM wrapper
https://npmjs.org/package/mysql - Driver
Bookshelf.js is also pretty good, but, in some aspects, not flexible. For example, you can not execute SQL request and convert result to models. So, use light-orm.