4

Is it possible to use for example Sequelize, Bookshelf or Waterline inside meteor ?

I want to use Meteor as a classic backend, so just using Restivus to build my Rest API and need to communicate with some external DBs. It doesn't need to be reactive or to be ''live query''.

Travis Webb
  • 14,688
  • 7
  • 55
  • 109
Yanis26
  • 247
  • 2
  • 13
  • it's a good question, I hope someone has done something like that and shares it – sites Apr 07 '15 at 05:31
  • I think if you want a great ORM in a node.js MVC framework, [**sails.js**](http://sailsjs.org) is your best bet. All that stuff comes built-in, and it supports over a dozen databases. – Travis Webb Apr 07 '15 at 18:52
  • @TravisWebb but I still want to use Meteor. I want to have 1 backend only instead of having two differents apps (meteor + sails/express ...). I find it weird that there are no examples of Meteor used as a classic Rest API backend with one of the ORMs. – Yanis26 Apr 08 '15 at 03:44
  • meteor is designed to power real-time web applications over websockets. I've never seen anyone try to use it as a REST API. That's not what it was made to do. The reason I suggested sails.js is that it is designed to be a REST API + ORM first, but also has real-time features – Travis Webb Apr 08 '15 at 03:46
  • This is on the Meteor roadmap. I asked one of the creators of Meteor, Matt Debergalis, this very question back at the Meteor 1.0 Meetup, and he said it was the most frequently requested feature, but they wanted to do it right, so it would be a bit before they had 1st party support. Still, it's important to them, and most of us in the community. You can see the roadmap here: https://trello.com/c/Gf6YxFp2/42-sql-support. He said SQL can definitely be configured to work reactively. We just need to be patient, or build it ourselves! You'll see some links in the roadmap comments to a few projects. – kahmali Apr 08 '15 at 06:05
  • @TravisWebb Check out mdebergalis' comment in the accepted response [here](http://stackoverflow.com/questions/10150538/how-to-expose-a-restful-web-service-using-meteor/27828110#27828110) and you can see one of the creators of Meteor would completely disagree with your suggestion that Meteor is not designed for REST APIs. There are legacy systems that require a REST interface, as well as public APIs where it's more likely developers will have experience working with REST than the very new DDP. If you don't have total control over your API consumption, you should probably be using REST still. – kahmali Apr 08 '15 at 06:21
  • @krose your answer that you link to admits meteor is not designed for this, and offers an add-on package that makes it possible. and your above comment says its still on the roadmap. so it looks to me like you're just proving my point. – Travis Webb Apr 08 '15 at 13:58
  • @TravisWebb Try again. And this time maybe do as my comment said and read the _comment_ by debergalis on the accepted answer. He's the creator of Meteor and his exact words are "Meteor's intended for this. It's just not written yet :) It's quite natural to map queries and mutations on a Meteor.Collection to a REST endpoint that clients written in any technology can call."... Well, I went ahead and wrote it with Restivus, which is definitely being used. So yeah, thanks for proving my point that folks like you would rather reason your way to your false assumptions rather than just reading a bit – kahmali Apr 08 '15 at 15:36
  • @krose I was looking for you everywhere but finally you came to me haha. I was going to use your package but I have some questions first : how's the performance compared to classical publish? Does it scale well? Can I trust it the same way I trust a framework only done for this (express)? Do you know any meteor app that uses it and uses a classic orm like sequelize or bookshelf or waterline to act as a classic rest api ? – Yanis26 Apr 08 '15 at 15:55
  • `Meteor's intended for this. It's just not written yet`. Yea, that makes no sense on its face. But carry on. – Travis Webb Apr 08 '15 at 16:29
  • @TravisWebb I also said that SQL support was on the roadmap (native REST support is as well, but there are already acceptable solutions for this), so I don't know why you mention that. And the fact that something requires an add-on meteor package does not mean that meteor wasn't designed to do that thing. It means Meteor was exactly equipped to do that sort of thing. We have to be a proactive community and not expect and wait on the core meteor developers to take care of everything for us! – kahmali Apr 08 '15 at 16:31
  • @krose Can you please guide me and answer the question I asked ? It's because I see no project using your package so that's why I want an example or to know if I can trust it. Thanks – Yanis26 Apr 09 '15 at 16:27
  • @skini26 Can you do me a favor and post those questions as [GitHub Issues](https://github.com/kahmali/meteor-restivus/issues)? Preferably each separately. That's the best way to get in touch with me directly with questions about Restivus. Also, its a better format and easier to find for future users. I can't stand these stack overflow comments. – kahmali Apr 09 '15 at 23:05
  • @TravisWebb I don't get it. Are you still trying to argue that people aren't using meteor to build REST APIs? Or are you just upset that Meteor is so much better than sails? So they built the superior node framework. Let it go. Look at the bright side, once they get native sql support, you can stop worrying about any sails development. It'll be completely obsolete. ....And don't get me wrong, I agree with you that the OPs best bet probably isn't meteor for what he needs, but there's no need to misinform anyone by saying nobody is building REST APIs in Meteor. You're wrong. – kahmali Apr 09 '15 at 23:37
  • @TravisWebb ...And the 1000+ installs on REST packages in Meteor suggests you're not just wrong, but extremely wrong. Not to mention my own REST API. Maybe do a little research next time before blindly promoting your software. Good day sir. – kahmali Apr 09 '15 at 23:39
  • Apparently I hurt your feelings at some point. I never said it's impossible, I said it's not the intended use case, and it's not meteor's core strength. OP even said they had trouble finding resources on this. Others on SO also have this impression, which is the very answer you linked to: http://stackoverflow.com/a/10151270/291180. If my information is outdated, that's fine; it's more indication that meteor wasn't originally built for this. Which is what I said in my first comment, which you took to mean... something else. – Travis Webb Apr 09 '15 at 23:54

1 Answers1

0

In principle you could, but since Meteor uses Fibers you would have to wrap calls. I had to migrate some sqlite3 data in the past and using a Fiber to wrap db calls worked. Was something like this

var Fiber = Npm.require('fibers');

db.method('query', function(){
  Fiber(function(){
    // more queries
  }).run();
});

Or around the same idea, I would have to look at the code to be sure but that was around those lines.

stringparser
  • 735
  • 1
  • 6
  • 16