Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration steps needed #8

Open
mmahmood opened this issue Jun 28, 2016 · 7 comments
Open

Migration steps needed #8

mmahmood opened this issue Jun 28, 2016 · 7 comments

Comments

@mmahmood
Copy link

Hi,
This is not really an issue. I need help on how to use your code.

I need to migrate my Parse.com app to Parse server now. I am done with the cloud code part, and now need to migrate a Parse-backbone website which was built using Parse JS SDK version 1.3.5. I am looking into my options at the moment. I am using requireJS. Can you please give me simple guidelines to migrate using backbone-parse-es6.
Here's my structure/ code:

Model:

define([
  'parse'
], function(Parse) {
    var InboxObject = Parse.Object.extend("Inbox",{
    initialize: function() {
    }
  });
  return InboxObject;
});

Collection:

define([
  'parse',
  'js/models/inbox'
], function(Parse, InboxObject) {
  var InboxCollection = Parse.Collection.extend({
    model: InboxObject
  });
  return InboxCollection;
});

View:

define([
  'jquery',
  'underscore',
  'parse',
  'js/models/inbox',
  'text!templates/inbox/detailsDialog.html'
], function ($, _, Parse, Inbox, DetailsDialogTemplate) {

    var DetailsDialogView = Parse.View.extend({
      template: _.template(DetailsDialogTemplate),

      el: "#messageDetailViewModal",

      initialize: function() {
        this.render();
        return this;
      },

      events: {
        "click .close": "close",
        "click .cancel": "close",
        "hidden.bs.modal #messageDetailViewModal": "close",
      },


      render: function() {
        var self = this;     
        inboxQuery = new Parse.Query(Inbox);
        inboxQuery.get(this.options.objectId).then(function(inbox){
              // some DB operations
        }, function (error) {
            // report error
        });
        return this;
      },

    });
    return DetailsDialogView;
});

What changes do I need to make if I simply replace parse.js reference with your backbone-parse-inclusive.js? You will save my hours if you assist me in that.

Thanks!
-Mariam

@typhonrt
Copy link
Member

typhonrt commented Jun 28, 2016

Luckily I actually have an ES5 / RequireJS example of consuming the AMD backbone-es6 bundle here: backbone-es6-localstorage-todos-requirejs-es5. It's not the Parse enabled version of the canonical TODOs demo.

In general you'd need to swap in the backbone-parse-es6 AMD bundle for the one provided in the demo above and add Parse to config.js and link it to the local version though there may be a caveat or two. I'll look into getting up the canonical Parse enabled TODOs demo w/ RequireJS & ES5 later this week.

FYI backbone-parse-inclusive.js is for global usage with no module system and is there for completion and not the recommended approach to use.

Hopefully there aren't too many differences between the older version of Parse that you've been using as well. You're definitely using the legacy form of working with Parse / Backbone. Basically anywhere you use Backbone functionality you'll have to import and use for instance Backbone.View.extend...

There are several JSPM / ES6 Parse demos here: typhonjs-demos, but I gather you might not have time to rewrite the app for ES6 though there are many benefits including great documentation via ESDoc.

Besides getting things to work first via RequireJS / ES5 on backbone-parse-es6 is a good first step.
You'll also have to let me know how things work out with Parse server. I haven't migrated anything (demos) yet.

@mmahmood
Copy link
Author

If I use your suggested demo, then I'd have to extend it to support Parse classes and override sync method to persist backbone models on Parse. I am actually currently testing my back-end, and was looking for options to migrate to on the admin console in the meantime. So if you plan to work on it soon, then I can wait :) It'll be a great help!!

Yes, we're using the legacy form of working with Parse. We've been v focused on adding more features and not on upgrading the app, which will not be v helpful I'm sure.

@typhonrt
Copy link
Member

backbone-parse-es6 handles all of the parse sync aspects transparently. It even supports serializing / deserializing nested Backbone models via Parse pointers transparently. See #5 for info on this. I'll hopefully have some time over the weekend to put up a RequireJS / ES5 backbone-parse-es6 demo.

backbone-parse-es6 also supports the legacy form of working with Parse.

@mmahmood
Copy link
Author

Thanks, I'll look into this. And RequireJS demo would be of great help!

@typhonrt
Copy link
Member

I definitely want to post an update as I've been busy finishing off a major rewrite of escomplex. There is lukewarm news.. It turns out the fix for #5 causes general problems with consuming backbone-parse-es6 directly in RequireJS. I have provided more details in an open issue on the Parse JS SDK repo. There is a simple solution, but requires a very small change to expose the full encode method in Parse. I've asked @andrewimm to take a look and consider the change.

@lkraider
Copy link

lkraider commented Mar 10, 2017

What parse.js versions can I use with this project?

@typhonrt
Copy link
Member

@lkraider it should work with the latest. If you use JSPM directly things are scoped '^1.0.0' and Parse is currently at 1.9.2. There are also bundles available including an inclusive global one though it's better to use the module ones in general. I haven't tested anything with a self-hosted Parse server since the service was discontinued. If there are problems please open other issues. I'm not sure when I'll get around to setting up a server of my own for further testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants