Create an app without Mongodb and use REST api with json returns instead

I am very new to Meteor and i’m wondering how can i use this awesome framework without Mongodb and get my datas from a REST api who return json.

Thank you!

It’s actually fairly easy to consume REST endpoints with Meteor (client-side and/or server-side). However, the mongo package is part of the build for the standard meteor-platform package, which makes it rather messy to physically remove it from your app.

It is much easier to start to work with Meteor if you accept that mongo is part of the platform. If you don’t want to persist mongo data to disk (“have a MongoDB database”) you don’t have to. You can take your REST data and insert it into a client-only Mongo.Collection, either directly within the client, or (in a more Meteor way) via a publication from the server. Alternatively, you can call a server-side Meteor method from the client to perform secured CRUD (assuming you right your code with this in mind).

Putting REST data into a Mongo.Collection makes it really easy to manipulate as MongoDB-like documents.

My apologies for the number of links, but I wanted to make it short, while still allowing you to get to the core documentation. :smile:

6 Likes

If i go fetch REST data and put it into a Mongo.Collection, it will be a
double DB application isn’t it? I create an app with a Java developper who
will create a web service REST api and i will retrieve informations from it.

Can you show me a little how to create a Mongo.Collection client only? Or
how can i retrieve the information and use the publication. Just a little way to do it right.

Thank you for your great answer! I just began the level up tuts tutorial on
meteor.js and it’s great!

Do the https://www.discovermeteor.com/packages#full-edition “Working With External APIs” part will teach me how to do it?

Thank you!

If you’re just trying to avoid mongo so you can use a SQL db with java, you might be better bypassing java and just directly hook into the database. There are several SQL interfaces on atmosphere: https://atmospherejs.com/?q=sql and here’s a good article on the current state of SQL with Meteor: https://www.compose.io/articles/meteor-sql-and-other-databases/

1 Like

Sorry for the delay replying - I had to re-read that chapter! :smile:

That looks like a good introduction and covers a lot of useful concepts. However, there are a number of steps in the tutorial which are not essential to understanding the concepts of REST access (package creation, settings.json, latency compensation, presentation of results). Note that these “extras” are undeniably an essential learning experience of Meteor, but are not essential to understanding REST endpoint access.

It was good to see that the topic of REST and reactivity is addressed. This is one of the biggest frustrations with REST in Meteor - we have this great, real-time platform and we can use it to access essentially static endpoints over REST. We then resort to horrible kludges like endpoint polling if we want to see “live” changes.

So, here’s a couple of things you may like to consider:

  1. Get your Java guy to provide a DDP endpoint for immediate, reactive updates to Meteor.
  2. (Alternatively), write the server-side code in Meteor and use simple:rest to provide a matching REST endpoint for non-Meteor clients.

As @schonne says, you can also consider SQL (reactive packages for MySQL and PostgreSQL are available).

1 Like

@robfallows @schonne @dwboutin
Hi guys, I build a web service REST API from meteor and the client is native
android java. I wanna upload file from my android using rest or ddp. but
until now, i havent found the solution about uploading file via ddp or
using rest. Anybody wants to help me?