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

Add API docs for the RecordReference #4641

Merged
merged 1 commit into from
Nov 20, 2016

Conversation

bmac
Copy link
Member

@bmac bmac commented Nov 11, 2016

No description provided.

Copy link
Member

@pangratz pangratz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 ❤️

```

@method id
@return {String} The id of the record in this belongsTo relationship.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/ in this belongsTo relationship.//

RecordReference.prototype.id = function() {
return this._id;
};

/**
How the reference will be looked up with it is loaded:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...up with when it is loaded:... ?

/**
How the reference will be looked up with it is loaded:

* `link`, a URL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I believe that this is not supported at the moment. At least I am not aware of this... What am I missing?

var userRef = store.getReference('user', 1);

// provide data for reference
userRef.push({ id: 1, username: "@user" }).then(function(user) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The data passed to push needs to be a JSON-API doc with { data: { ... } }

RecordReference.prototype.push = function(objectOrPromise) {
return Ember.RSVP.resolve(objectOrPromise).then((data) => {
return this.store.push(data);
});
};

/**
If the entity referred to by the reference is already loaded, it is
present as `reference.value`. Otherwise, the value of this property
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change this to: Otherwise the value returned by this function is null

@bmac bmac force-pushed the record-reference-api-docs branch 2 times, most recently from 3e9a39c to 717bdff Compare November 18, 2016 14:43
@locks
Copy link
Contributor

locks commented Nov 20, 2016

@pangratz can you re-review?

@pangratz pangratz merged commit 96ecf96 into emberjs:master Nov 20, 2016
@pangratz
Copy link
Member

Thanks again @bmac

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

Successfully merging this pull request may close these issues.

3 participants