Search code examples
node.jsangularjsmongodbbreezemiddleware

Get all in MongoDB collection using SocialCMS with Breeze


I'm using SocialCMS Database middleware https://github.com/dai-shi/social-cms-backend with BreezeJS support.

I'm able to save changes to a MongoDB collection fine using manager.saveChanges() and manager.acceptChanges() and retrieve records in local cache using getEntities()

Using this middleware

With BreezeJS support:

var SCB_options = {
  mongodb_url: 'mongodb://localhost:27017/socialcmsdb',
  breeze_mongo: true,
  routes: [{
    object_type: 'user',
    object_prefix: '/breeze-service/users'
  }, {
    object_type: 'post',
    object_prefix: '/breeze-service/posts'
  }, {
    object_prefix: '/breeze-service/SaveChanges'
  }]
};

How do I retrieve all remote records belonging to a particular route? For example, I want to retrieve all total posts remotely not in the users cache.

Do I modify app.js, my Angular apps datacontext, both or neither?


Solution

  • I solved this problem. It's a bit hard to discern from the Social CMS docs that the routes are local first. Which is great if you want to route without internet access! But I needed to create new routes outside of the SCB_options in order to request mongoDB directly.