1

I would like to use StrongLoop Loopback as a Node.js backend API for a backbone.js app.

Is there a way to define models attributes and methods (for example, for validation) that can be used both on the client side, in the backbone model, and on the server, in Loopback models definitions ? (Dont Repeat Yourself philosophy)

Loopback uses model definitions to initialize objects

Maybe I can extend Backbone.Model to be able to load the Loopback model definition syntax ?

Do you think it's a good idea / easy task ?

Craig Ringer
  • 307,061
  • 76
  • 688
  • 778
Pandaiolo
  • 11,165
  • 5
  • 38
  • 70

1 Answers1

2

disclosure: I do front-end work for StrongLoop.

It is a good idea since the model definitions are stored as simple json. You can also use the API explorer output to pick up the url path properties as well.

We are just wrapping up a similar thing for AngularJS to auto-gen a model factory you can drop into your client modules and it's pretty slick so hopefully a Backbone version won't be too far behind.

user3259256
  • 192
  • 7
  • 1
    That would be DEFINITELY useful ! I can't wait to see the "coming soon JS SDK" advertised in the docs, do you know how far the release is from now ? – Pandaiolo Feb 01 '14 at 13:45
  • 1
    I'll try to write a complete answer here with the `Backbone.Model` class extension doing the job, in a few weeks. – Pandaiolo Feb 05 '14 at 14:08
  • 1
    Hi, I'm going to do `Backbone.Model` extension too. Do you have any positive results? Thank you in advance – darknos Mar 12 '14 at 08:01
  • 1
    @Pandaiolo have you had time to write up a complete answer yet? – Drastick May 16 '14 at 14:18
  • 1
    Not yet, I am waiting for [this full stack example](https://github.com/strongloop/loopback-example-full-stack) to be more complete. However, I switched to Angular as there is a very convenient resource object generator available for Loopback. – Pandaiolo May 17 '14 at 16:30
  • This would be very valuable, I think. +1 – Eric Knudtson Dec 11 '14 at 02:25