Skip to content

Instantly share code, notes, and snippets.

@bobjackman
Last active December 20, 2015 18:38
Show Gist options
  • Save bobjackman/6176984 to your computer and use it in GitHub Desktop.
Save bobjackman/6176984 to your computer and use it in GitHub Desktop.
Ember-Data Example URLs
code alternative code url expected response
App.store.findById(App.User, 123) App.User.find(123) https://www.example.com/myNamespace/users/123 {user:{ ...user123... }}
App.store.findAll(App.User) App.User.find() https://www.example.com/myNamespace/users {users:[{ ...user1... },{ ...user2... },{ ...userN... }}
App.store.findMany(App.User, [1,2,3]) not supported https://www.example.com/myNamespace/users?ids[]=1&ids[]=2&ids[]=3 {users:[{ ...user1... },{ ...user2... },{ ...user3... }}
App.store.findQuery(App.User, {firstName: 'Bob'}) App.User.find({firstName: 'Bob'}) https://www.example.com/myNamespace/users?firstName=Bob {users:[{ ...user1... },{ ...user2... },{ ...userN... }}

#Get One Model

Calling Code:

App.store.findById(App.User, 123)

or

App.User.find(123)

Generates URL

https://www.example.com/myNamespace/users/123

Expects Response

{
	user: { ...user123... }
}

#Get Some Models

Calling Code:

App.store.findMany(App.User, [1,2,3])

Generates URL

https://www.example.com/myNamespace/users?ids[]=1&ids[]=2&ids[]=3

Expects Response

{
	users: [
		{ ...user1... },
		{ ...user2... },
		{ ...user3... }
	]
}

#Search for Models

Calling Code:

App.store.findQuery(App.User, {firstName: 'Bob'})

or

App.User.find({firstName: 'Bob'})

Generates URL

https://www.example.com/myNamespace/users?firstName=Bob

Expects Response

{
	users: [
		{ ...user1... },
		{ ...user2... },
		{ ...userN... }
	]
}

#Get All Models

Calling Code:

App.store.findAll(App.User)

or

App.User.find()

Generates URL

https://www.example.com/myNamespace/users

Expects Response

{
	users: [
		{ ...user1... },
		{ ...user2... },
		{ ...userN... }
	]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment