GithubHelp home page GithubHelp logo

clintjhill / ember-parse-adapter Goto Github PK

View Code? Open in Web Editor NEW
190.0 190.0 53.0 3.12 MB

An Ember Data Adapter for Parse

Home Page: http://clintjhill.github.com/ember-parse-adapter

License: MIT License

JavaScript 88.61% HTML 2.71% CSS 0.18% Handlebars 8.50%

ember-parse-adapter's Introduction

ember-parse-adapter's People

Contributors

clintjhill avatar gcollazo avatar jacobthemyth avatar jgable avatar mixonic avatar notmessenger avatar thadd avatar ymainier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ember-parse-adapter's Issues

additional user attributes

I'm having fun trying your adapter but I was wondering if it's possible to add more attributes to User Model.

App.User = DS.ParseUserModel.extend({
    posts: DS.hasMany('post')
});

Something like this doesn't work.
Is there another way to do it?

Also is there a way to access the model through store?

var user = this.store.find('user');
user.get('username')  

returns undefined even though username is in DS.ParseUserModel.

I'm still a student so I'm not sure if these are dumb questions but if you could help me with them that would be great! thanks

Pull Request #26 breaks findQuery

Pull request #26 breaks the ability to use parameters that should not be wrapped in where. For example, I use custom include parameters for deeply nested structures, order, limit, skip, keys, count, etc. The Ember data docs say that findQuery exposes the underlying adapter semantics (see http://emberjs.com/api/data/classes/DS.Store.html#method_findQuery), so it puts the onus of responsibility on the developer to know how to craft a query. Automatically wrapping the query with where not only tries to hide the adapter semantics, but breaks code that uses the adapter semantics correctly.

Synchronize Page and README

I've noticed a couple of doc discrepancies between the GitHub page and the project's README.
Both should be revised so developers won't get lost with different instructions.

Examples:

  • how to install
  • needed keys
  • where to place the keys

Security with this adapter, and parse.js absence.

I've been looking through the code and cannot see the parse library loaded from eg:

<script src="//www.parsecdn.com/js/parse-1.4.2.min.js"></script>

How do we actually communicate with parse without this lib?

Also I am wondering how secure user data is in our applications, how do we inforce it with this adaptor. I only want the data held in parse to be shown to the relevant parse user once the log in.

Tag new release for bower

I've been playing around with the new version in the dist folder from yesterday and was wondering if/when you are going to tag/publish it for bower installs?

Any way to move keys outside of the ember app to hide them?

I'm loving this adapter, it's working great and is talking to my parse database perfectly and just how I expect it to work.
My only concern is with security, since the keys are in the app.js file anyone who knows what they are looking for can grab my keys and potentially get ad my data and mess with it.
Is there a way that I can remedy this by somehow abstracting the keys outside of the app.js file and still work with parse? Or am I just being paranoid and this isn't really an issue?

Extending ParseUser causes wrong API urls to be called

I have a few more extra fields on my Parse User table and so wanted to extend the EmberParseAdapter.ParseUser model with one specific to my app.

This causes creation of new Users to be put into a new Parse table called User, rather than into the special Parse _User table. It seems to be due to the way the adapter handles detecting the special parse _User type in the pathForType method?

pathForType: function(type) {
  if ("parseUser" === type) {
    return "users";
  } else if ("login" === type) {
    return "login";
  } else {
    return this.classesPath + '/' + this.parsePathForType(type);
  }
},

(code taked from line 21+ in adapter.js)

Am I doing something wrong, or should the way in which the special _User class is being detected be improved?

PS: This probably causes issues with the belongsTo and hasMany serializer, as they both use a similar detection mechanism in the parseClassName method in the serializer.

Dates not stored in ISO format results in 400 error from Parse on update

I'm learning Ember and am converting the TodoMVC app to use Parse as my store, but when it downloads the todos from Parse, they come in as strings which prevents them from being stored in ISO format. This then screws things up when you push an update to Parse because the date is in the wrong format.

I've taken two different approaches to solving this and both work. First, if a data object comes in as a string, you can create a Date from that string and store it as ISO:

  normalizeAttributes: function(type, hash){
    type.eachAttribute(function(key, meta){
      if(meta.type === "date" && Ember.typeOf(hash[key]) === "object"){
        hash[key] = hash[key].iso;
      } else if(meta.type === "date" && Ember.typeOf(hash[key]) === "string"){
        hash[key] = new Date(hash[key]).iso;
      }

      if(hash[key] === undefined) {
        hash[key] = this[key];
      }
    });

    this._super(type, hash);
  }

The other alternative was to simply delete the createdAt and updatedAt keys from the hash in serializeIntoHash.

Both these approaches allowed my updates to go through just fine. I tried with both Beta and Canary versions of Ember and Ember-Data.

Collaboration: ember-parse <> ember-parse-adapter

Hi @clintjhill,

I just uploaded a fork of this repo to https://github.com/GetBlimp/ember-parse. One of the main differences is that I'm using the JavaScript Key instead of the REST API Key.

My decision not to use the REST API Key was based on a conversation I had with a friend who works at Parse. He told me that as a general rule the REST API Key should be kept secret. He cited a few reasons for that but I only remember one: "turning off client side push does not affect the REST API Key".

I also had a few problems with relationships with the current adapter and needed a way to do authentication. For auth I wrote a service which is injected to routes, controllers and components and provides methods to authenticate, invalidate, sign up and request password reset. This session service is implemented without any external dependencies.

For my adapter and serializer I basically copied the code from this repo and fixed the issues I came across with. As of right now I think almost everything is working (for my use cases). I have to admit that to solve some issues I had to hack my way through. I know it can be better.

I would like to propose a collaboration between both maintainers to make this addon better for all. I'm open to feedback or any suggestions. I would love to work together to build a shared solution.

๐Ÿ˜„ What do you say?

Filtering by ParseUser

How would one go about filtering on a route's model function by a belongsTo field on a model. I'm currently doing something like, which feels odd. createdBy is a belongsTo(had to set async to false) field on a task model.

  model: function() {
    var session = this.get('session');

    return this.store.filter('task', {}, function(task) {
      return task.get('createdBy.id') === session.get('id');
    });
  }

I also tried something like the following, which didn't work at all.

  model: function() {
    var session = this.get('session');

    return this.store.filter('task', {
      createdBy: this.store.find('parse-user', session.get('id'))
    });
  }

Session token should be included if there's a current user

If a user is logged in, then all requests to Parse should include the session token so that Parse's ACLs can be enforced. I was able to fix this in my app by adding the session token in the adapter's init, but I'm not 100% sure that that will work robustly as user's log in/out.

var ParseAdapter = DS.ParseAdapter = DS.RESTAdapter.extend({

  defaultSerializer: 'Parse',

  init: function(){
    this._super();
    headers = {
      "X-Parse-Application-Id": this.get('applicationId'),
      "X-Parse-REST-API-Key": this.get('restApiId')
    };
    if(typeof(localStorage) !== undefined){
      var emberParseUser = JSON.parse(localStorage.getItem("ember_parse_user"));
      if(typeof(emberParseUser.userId) !== undefined){
        headers["X-Parse-Session-Token"] = emberParseUser.session;
      }
    }
    this.set('headers', headers);
  },

Not sure if you think this is the best approach so I'm not submitting a PR yet.

Error when trying to load data from Parse

Hi I just tried out your parse adapter. I'm just learning how to use Ember, but I was interested in starting to play around with Parse. The request is being made and data is returning however the following error is showing up in the console:

Error: assertion failed: Your server returned a hash with the key activity but you have no mapping for it

Documentation on Relations

Fussing around the code, trying to squash a bug, I discovered there are options for relationships that would enable us to use different Parse types.
On top of that, it seems the default type for hasMany relations is not supported, since it sends an object to Parse but Ember expects back an array; I guess relationship.options.array should be default, not optional? Refs #66

Is there any documentation on this? I couldn't find any...

I may be able to get a look at this if there's no one more capable for the task.

RecordArrays no longer tracking `deletedItems`

Noticed today that after Merge of #21 deletedItems in a hasMany recordArray is no longer being tracked, which breaks the patch style array/relation updates here and means you can't remove an item from a Parse Array (such as a hasMany array) and have that change be picked up by Parse.

https://github.com/clintjhill/ember-parse-adapter/blob/master/lib/ember-parse-adapter/serializer.js#L189

I was working on a few different ways to add this back, but couldn't determine a reliable method. It would be nice to not have to rely on tracking "deletedItems" in the record array, and instead do like a diff of the changedAttributes - but it looks like the changedAttributes method does not work properly for record array type attributes.

How to use Array for the "one" in one-to-many relations?

I have a model with a belongsTo relation, that in Parse is an Array column.

However, using model.set('column', [relationModel]) triggers an error: "Assertion Failed: You cannot add a 'undefined' record to the 'hypothesis.risk'. You can only add a 'item' record to this relationship."

I guess this happens because the belongsTo relation specify a model class, but how should we specify those instead? I wanted to use an Array column for a one-to-many relation, so it would load the "one" side instantly - instead of using Pointer, that would make a second request to get the "one" (this is advised in the parse docs).

Missing model attributes after creating/updating a record

I'm new to Ember, but in trying to port the TodoMVC app to use Parse I have almost everything working except when I create or update a record. When the response comes back from Parse, it only includes the objectId and createdAt or just updatedAt for create and update actions respectively. Looking at the Ember test cases, it's clear that it expects REST APIs to return the full JSON for the object on create and update calls.

The problem is that this clears the other attributes until you refresh the object. I may be misunderstanding how to sync/refresh my objects properly.

Relationships are not persisted correctly

When trying to store a relationship in Parse I get the following 111 error in the HTTP response: invalid type for key customer, expected relation<Item>, but got "Item"

The payload sent includes a customer key with this object: { __type: "Pointer", className: "Item", "objectId": "D2zBq..." }

That was made through the console, with the following code just for the purpose of testing how things work:

models = controller.model;
models.hypotheses.objectAt(0).set('customer', models.customers.objectAt(0));
models.hypotheses.objectAt(0).save();

I guess the adapter is not correctly naming relationship objects before sending?

sessionToken in custom adapters

It looks like this is maybe a limitation of Ember-Data itself, but I was wondering if anyone else has experienced this issue. Basically, if I have a custom adapter for one of my models:

import ApplicationAdapter from './application';

var PostAdapter = ApplicationAdapter.extend({
  // ...
});

export default PostAdapter;

When I make a call that requires authentication, it doesn't have access to the headers.X-Parse-Session-Token property. This makes perfect sense, since the property is stored on an instance of ApplicationAdapter, not on the constructor. The other headers work fine since they're set up on the constructor level. Any ideas on how to fix this?

multiple requests hasMany relationship

I simplified code to show relevant issue.

Ember data models:

var page = DS.Model.extend({
    categories: DS.hasMany('category', {async: true}),
});

var category= DS.Model.extend({
    page: DS.belongsTo('page', {async: true})
});

In Parse I have relevant columns:

I have page pointer type from category -> page
I have categories array of category objectId's on each page.

When I have instance of page and try this method:

page.get('categories')

or call (in template to iterate):

page.categories

Parse data adapter makes individual GET requests for each categories.
ie: say for example Page has categories array set as ["dyutrdf23", "44fdfdf"]
will make two requests to get the categories.

I modified model hook on Categories route to make one request to fetch all page categories:

    var page = this.modelFor('page');
    return this.store.find('category', {
        where: {
            page: {
            "__type":  "Pointer",
            "className": "Page",
            "objectId": page.get('id')
            }
        }
    });

This works, I used it from https://github.com/clintjhill/ember-parse-adapter/blob/master/addon/adapters/application.js#L130.

However, I don't understand why this method (findHasMany) is not being called (for one request with query as opposed to individual requests) when I make the page.get('categories').

Maybe I've overlooked something with Ember data/Ember parse adapter here.

Any feedback appreciated. Thank you.

Refreshing page for nested resource referenced via dynamic segment silently fails

I can successfullly navigate to a URL like this:

  • Load page at this address:

http://localhost:5000/

  • Automatically redirected (via IndexRoute) to here:

http://localhost:5000/#/wallets

  • Clicking on a 'wallet' link in an enumberable gets me here just fine:

http://localhost:5000/#/wallets/9kWTXhv8ZQ

However, if at this point I reload the page, ember silently fails -- rendering nothing, displaying only a blank page. No errors.

I can see in the networking tab of the js debugging panel in chrome that:

A) a request to load https://api.parse.com/1/classes/Wallet is executed Successfully.
B) a request to load https://api.parse.com/1/classes/Wallet/9kWTXhv8ZQ is executed successfully.

Swapping out ParseAdapter for FixtureAdapter, reloading the page at this point works just fine.

I don't have a lot to go on here so I'm hoping you can help me out with this. Happy to give you the source to my project.

I am using revision 12 of Ember-Data.

Following are the full ember.js logs for the request:

STATEMANAGER: Entering rootState.empty application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'loadingData' to state rootState.empty. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Entering rootState.loading application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'loadedData' to state rootState.loading. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'materializingData' to state rootState.loading. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Entering rootState.loaded application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Entering rootState.loaded.materializing application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Entering rootState.loaded.materializing.firstTime application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'willSetProperty' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'willSetProperty' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'willSetProperty' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'didSetProperty' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'didSetProperty' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'didSetProperty' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'finishedMaterializing' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Entering rootState.loaded.saved application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Entering rootState.empty application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'loadingData' to state rootState.empty. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Entering rootState.loading application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'loadedData' to state rootState.loading. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'materializingData' to state rootState.loading. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Entering rootState.loaded application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Entering rootState.loaded.materializing application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Entering rootState.loaded.materializing.firstTime application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'willSetProperty' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'willSetProperty' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'willSetProperty' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'didSetProperty' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'didSetProperty' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'didSetProperty' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'finishedMaterializing' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Entering rootState.loaded.saved application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'loadedData' to state rootState.loaded.saved. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'materializingData' to state rootState.loaded.saved. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Entering rootState.loaded.materializing application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'willSetProperty' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'willSetProperty' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'willSetProperty' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'didSetProperty' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'didSetProperty' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'didSetProperty' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Sending event 'finishedMaterializing' to state rootState.loaded.materializing. application-ea349f1eb898e16369320ffe8c8d22c6.js:12193
STATEMANAGER: Entering rootState.loaded.saved

Can't get sessionToken

For some reason, setting the sessionToken works, but getting doesn't.

var adapter = container.lookup('adapter:application');
adapter.set('sessionToken', 'foo');
adapter.get('headers.X-Parse-Session-Token');
// => 'foo'
adapter.get('sessionToken');
// => <the adapter instance>

If I add logs to sessionToken:

sessionToken: Ember.computed('headers.X-Parse-Session-Token', function(key, value){
    console.log('calling sessionToken');
    if (arguments.length < 2) {
      console.log('getting sessionToken');
      return this.get('headers.X-Parse-Session-Token');
    } else {
      console.log('setting sessionToken ' + value);
      return this.set('headers.X-Parse-Session-Token', value);
    }
  })

when I call adapter.set('sessionToken', 'foo'), I see:

> calling sessionToken
> setting sessionToken foo

when I call adapter.get('sessionToken'), there are no log statements.

It's kind of tough to set up a jsbin with all the dependencies, but if this isn't clear enough, let me know and I'll see what I can do.

Better explanation on how to use the addon

I'm having some trouble getting the package to decent usage (at least, for a newbie).

  1. installation was troublesome, since the addon is not available and had to dig through the issues to find a way to install it through npm
  2. how do we setup it? Project page and readme says two different things
  3. no place explains how to import/instantiate/whatever the package. I couldn't find anything useful in the demo app as well. It seems to be working but I can't understand how, to try to reproduce it with the npm package I got.

How will newbies survive? :(

CloudCode Functions?

Is there a way to get cloudcode functions working? I want to be able to query a certain model with a POST request, passing in geolocation data.

POST http://api.parse.com/1/functions/proximity

with

{
lat: 51.0453738,
lon: -114.0566039,
limit: 20, radius: 10,
parseClass: "Event",
distance: 2
}

Is this possible yet? If not, how can it be implemented?

Getting errors on initialization

DEBUG: ------------------------------- ember-1.5.1.js:3521
DEBUG: Ember : 1.5.1 ember-1.5.1.js:3521
DEBUG: Ember Data : 1.0.0-beta.2 ember-1.5.1.js:3521
DEBUG: Handlebars : 1.1.2 ember-1.5.1.js:3521
DEBUG: jQuery : 1.10.2 ember-1.5.1.js:3521
DEBUG: ------------------------------- ember-1.5.1.js:3521
Uncaught Error: Assertion Failed: No application initializer named 'ember-data' ember-1.5.1.js:73

ACL workaround

Hey, I know ACL is on the roadmap but is there some workaround so I can use it with the current version?

ember install gives -> 404 Not Found: ember-parse-adapter

I tried this last night, but its not working.

ember install:addon ember-parse-adapter
version: 0.1.15
Could not find watchman, falling back to NodeWatcher for file system events
404 Not Found: ember-parse-adapter
Error: 404 Not Found: ember-parse-adapter

Cache the user in local storage

Are there any plans to cache the logged in user so the user doesn't have to login every time they visit the app?

On a related note, is the goal to implement all the same features as the official Parse javascript SDK?

Error when using with ember-cli

Setting up with ember-cli had a few different steps which I could write up some Wiki docs for if you would like. It was simply breaking apart the single file into different initializers.

But aside from that, I ran into a problem with the following code:

pathForType: function(type) {
    var factory = this.container.lookupFactory('model:' + type);
    if(DS.ParseUserModel.detect(factory)){
      return "users";
    } else if(type === "login") {
      return type;
    } else if(factory.toString().indexOf("subclass") > 0) {
      // This condition added specifically for the case where modules are involved
      // and the type is not explicit. Ember App Kit in particular needs this.
      return this.classesPath + '/' + Ember.String.capitalize(type);
    } else {
      return this.classesPath + '/' + factory.parseClassName();
    }
  },

Where else if(factory.toString().indexOf("subclass") > 0) would not evaluate to true, causing my URL to go to something like projectname@model:modelname: and eventually erroring out with a No 'Access-Control-Allow-Origin' header is present on the requested resource error.

With a model of skill it would try to use projectname@model:skill:, therefor no "subclass" existed in the string and it would not apply the fix for App Kit style.

I am not sure if this is caused by my usage of ember-cli or something else... If I can help provide any more information on this problem, let me know and I can try to re-trace it better.

Error when saving record which has many children

When saving a record with many children, when serializing, an error is thrown in the serializeHasMany function of EmberParseAdapter.Serializer line 184.

      "className": child.parseClassName(),

The parseClassName function does not exist on the child record. This seems like an issue - is it supposed to be calling the parseClassName method on the serializer/adapter rather?

I got around this in my code by implementing a parseClassName method on my own model, which just returns the parse class name of that model.

Seems like a fix would be to change this line to call the parseClassName method on the serializer, rather than the non-existent method on the child model. Does that sound OK, or am I getting confused somewhere?

I'll make the fix if my solution sounds fine.

Create Ember CLI addon

This is already an awesome adapter, and it would be cool to have an ember-cli addon as they released this feature recently and it significantly reduces installation time. Is this in the roadmap?

Thanks :)

'typeKey' error in ember-data code

I get this error when a payload of Parse Objects are received:

'Cannot read property typeKey of undefined'

After digging up the ember-data code, I managed to fix the issue by changing the following method:

function deserializeRecordId(store, data, key, relationship, id) {
if (!Model) { Model = requireModule("ember-data/lib/system/model")["Model"]; }
if (isNone(id) || id instanceof Model) {
return;
}

            var type;

            if (typeof id === 'number' || typeof id === 'string') {
                type = typeFor(relationship, key, data);
                data[key] = store.recordForId(type, id);
            } else if (typeof id === 'object') {
                // polymorphic
                /*
                 * OLD CODE
                 * data[key] = store.recordForId(id.type, id.id);
                 */
                /*
                 * Begin modification
                 */
                var ID = id.id;
                var TYPE = id.type;
                if(!ID)
                    ID = id.objectId;
                if(!TYPE)
                    TYPE = id.className;
                data[key] = store.recordForId(TYPE, ID);
                /*
                 * End modification
                 */
            }
        }

I've had this issue right form the start, but managed to 'fix' it by directly editing the ember-data code. However, I need a more permanent solution. Any ideas?

hasMany relations are not stored correctly

It seems the adapter has trouble when dealing with hasMany relations.

Namely, I created an Array column, but got 400 as the adapter sends in an OBJECT in place of a list of items.
Then I changed the column into type object. What's my surprise when Ember refuses to load my record since hasMany should be an array, not an object?

A (subclass of DS.Model) record was pushed into the store with the value of boards
being '{objects: [object Object]}', but boards is a hasMany relationship so the value
must be an array.

How do I use ParseUser properly?

Hi Clint.

First of all, thanks so much for building this. Although I'm a newcomer to Ember, I really love the way it manages state and URLs, and look forward to becoming much more familiar with it.

I'm building my first proper Ember app using Ember Parse Adapter, and I'm trying to create a new Parse user using ParseUser, unsuccessfully thus far. I'm attempting to do this in a similar fashion to creating a new "Sample", by creating a function on the new user form submit, that references a user modal, which in turn extends the ParseUser mixin:

  RollSlow.UsersNewView = Ember.View.extend({
    submit: function(evt){
      var user = RollSlow.UserModel.createRecord();
      user.set('username', this.$('input[name=userName]').val());
      user.set('email', this.$('input[name=userEmail]').val());
      user.set('password', this.$('input[name=userPass]').val());
      // This is now going to persist the new User to Parse.com
      user.get('store').commit();
      return false;
    }
  });

which refers to the following model:

  RollSlow.UserModel = ParseUser.extend({
      username: DS.attr('string'),
      email: DS.attr('string'),
      password: DS.attr('string')
  });

However, this obviously isn't working, otherwise I wouldn't be pestering you here.

Do I need to refer to ParseUser directly in the submit function rather than a UserModel? Perhaps I need to call user.signUp() rather than user.get()?

Thanks for any insight you can give me!

Data from belongsTo which is 'included' in the ParseQuery is still loading asynchronously.

I am trying to get an array of a Parse Class called Test which has a property called category: a pointer to the Category Class. I get this array of Test using the following code:

this.store.findQuery('test', {
            where: JSON.stringify(query),
            include: "category",
            order: "title"});

It returns everything perfectly fine with the category object loaded into each Test object.

However, looking at my developer's console, I can see that Ember makes a network call to Parse every time I do:

test.get('category');

In my Test Model class, I have set the category attribute as this:

export default DS.Model.extend(ParseMixin, {
           category: DS.belongsTo('category', {async: false})
});

This is causing me problems with my logic as I need the test.get('category') call to be synchronous. Any ideas where I might be going wrong? I've only started learning Ember a few weeks ago and starting learning how to code just over a year ago so bare with me please.

Data not being sent to Parse.com

Hi I'm running the Ember App Kit by Stefan Penner with Parse.com and your adapter. I've got everything set up but when I try to create a new user, it doesn't seem to be writing back to Parse. My data only submits to local storage. Any ideas what I might be doing wrong?

Publish new version of the library

Now that this library has been converted to an Ember CLI Addon I recommend bumping the version number to 0.6.0 or 1.0.0 - something to indicate that there has been a backwards-compatibilty break - and tagging a release and publishing it to npm. This will address #55 that users are experiencing in attempting to install this Addon via the Ember CLI ecosystem.

It will also help make the transition away from Bower - #24

Custom find queries.

There doesn't seem to be any obvious way to make a custom where query.

I had a guess and tried the following but it didn't work:

var test = this.modelFor('test');
var questions = this.store.find('question', {where: {test: test} });

Any ideas? Is there a wiki?

Intended use for signup?

This may be a newb question, but I am wondering how ParseUser.signup is intended to be used?

Here I am creating a user if none exists for testing:

// app/models/parse-user.js

import ParseUser from 'ember-parse-adapter/models/parse-user';
var User = ParseUser.extend();
export default User;

//app/routes/user.js

import Ember from 'ember';

export default Ember.Route.extend({

  model: function() {
    var that = this;
    return this.store.find('parse-user').then(function() {
   // create user if one doesn't exist
      if (that.store.getById('parse-user', 1) == null) {
       // Having to pass that.store here?
        that.store.modelFor('parse-user').signup(that.store,{
          id: 1,
          username: 'user',
          password: 'password',  
          email: '[email protected]'
        });
      }
    });
  }
});

HABTM Relationship

I'm trying to model a HABTM relationship. I've tried a couple of different ways but I keep getting errors. Is there a tested/standard way to model a HABTM relationship with this adapter?

The relationship I'm modeling is a message which hasMany recipients (a recipient is a parse-user). The first thing I tried was to create a relation column in Parse on my Message class and make my model look like -

App.Message = DS.Model.extend({
     recipients: DS.hasMany("parse-user", { relation: true })
});

But then if I do a record.get("recipients") I get:

TypeError: undefined is not a function
    at buildRelationship (https://github.com/emberjs/data/blob/master/packages/ember-data/lib/system/relationships/has_many.js#L86)

Delete Record is not sending DELETE requests

When calling destroyRecord on a model, a PUT request is sent instead of a DELETE request. E.g., the updateRecord method is called. I noticed the adapter doesn't contain a deleteRecord method.

I'm doubly confused about why the updateRecord method is called when trying to save a delete record. Is this a default behavior of ember-data? I even added my own deleteRecord method to a local copy of the adapter and updateRecord is still being called.

I know from reading the Parse docs that there are specific instances where you delete things via a PUT request (updateRecord), like entries in an array data type (which I believe is related to #28). In my case I'm talking about the basic /1/users/<objectId> DELETE call.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.