2

I'm reviewing various frameworks for node.js and I'm just now testing Sails.js by writing a small CRUD app. I would like to know if there is an elegant way to use a different ORM other than the one sails includes.

I haven't seen anything in the documentation in Sails.js for using a different ORM. Are there any "integrated" non-orm specific features that I may be missing by attempting to use a different ORM?

programmer
  • 1,096
  • 1
  • 13
  • 31

3 Answers3

1

Waterline should be considered a core part of sails. There isn't any easy way to replace it with a different ORM. In the google group for Sails.js, Mike McNeil (the creator of sails) acknowledges that Sails is not currently built to support swapping in a different ORM[1].

"[...]I'm totally open towards efforts to extend Sails to support other ORMs[...]"

[1] https://groups.google.com/d/msg/sailsjs/jmR36bD-Zys/-F0ZFy1Q1IoJ

Chad
  • 2,161
  • 1
  • 19
  • 18
1

In the upcoming v0.10 release of Sails the hooks and generators have been broken out and can easily be replaced to support whichever ORM you would like to use.

The community will be able to write ORM-loaders to replace the Waterline ORM loader and a generator to generate models in the correct format for the ORM of your choice. Custom blueprint controllers will also need to be written to talk to the ORM.

It's a lot of work but something that should start to happen once a stable v0.10 is released.

particlebanana
  • 2,416
  • 21
  • 22
0

I wrote up the steps to consistently disable waterline throughout sails (v0.10, v0.9.8) here: https://stackoverflow.com/a/21612024/3263412

Without replacing the orm hook you definitely loose a big chunk of Sails' features, at least until the eco system particlebanana describes is developed:

  • pubsub
  • blueprints and rest routes (but could be worked around easily)
  • model scaffolding
  • custom adapters

On the other hand i figure it would not be too incredible hard to write up an orm hook for node-orm2 or sequelize plus the facades the other Sails hooks would probably need to work properly.

Community
  • 1
  • 1
marionebl
  • 3,342
  • 20
  • 34