1

I come from a Java world where we have JPA && JPAQL to handle the object->relational mapping. Is there something similar in node? I'm not talking about a driver to issue SQL statements, but a true object layer library.

I found the orm package, but I want to make sure there isn't one that's essential become the standard-bearer (unless orm is it).

John Manko
  • 1,828
  • 27
  • 51

1 Answers1

2

Yes there is.

Sequelize

It looks pretty straight forward to use it:

var Sequelize = require('sequelize');
var sequelize = new Sequelize('database', 'username', 'password');

var User = sequelize.define('user', {
  username: Sequelize.STRING,
  birthday: Sequelize.DATE
});

sequelize.sync().then(function() {
  return User.create({
    username: 'janedoe',
    birthday: new Date(1980, 6, 20)
  });
}).then(function(jane) {
  console.log(jane.get({
    plain: true
  }));
});

There is also this one: Which ORM should I use for Node.js and MySQL?

Community
  • 1
  • 1
Jey
  • 118
  • 6