Ember數據中是否有findMany方法?我需要手動調用它 - 例如,Ember中的findMany數據
App.Person.findMany([1, 2, 3]);
我一直看到它在附着到商店或模型文章/博客/例子,但它不是在我的應用程序上來。
如果實施,我該如何使用它?
如果沒有,有人能指出我如何實施它的正確方向嗎?
Ember數據中是否有findMany方法?我需要手動調用它 - 例如,Ember中的findMany數據
App.Person.findMany([1, 2, 3]);
我一直看到它在附着到商店或模型文章/博客/例子,但它不是在我的應用程序上來。
如果實施,我該如何使用它?
如果沒有,有人能指出我如何實施它的正確方向嗎?
我不知道是否有findMany
的別名,但您可以直接使用商店。 現場演示http://jsfiddle.net/marciojunior/sxLf3
store.findMany(App.User, [2,3]);
您可以通過類似App.Post.find({IDS:[1,2,3]}),這將查詢:
/posts?ids%5B%5D=1&ids%5B%5D=2&ids%5B%5D=3
在軌(或插入你的服務器端語言選擇),你可以這樣做:
class PostsController < ApplicationController
def index
if ids = params[:ids]
@posts = Post.where(:id => ids)
else
@posts = Post.scoped
end
respond_with @posts
end
end
還有一些其他的方法來做到這一點,但灰燼數據可以改變不時這種方法往往不破。
就是這樣 - 謝謝! –
我不知道這是否是正確的答案。這個問題與ember-data相關,而不是rails。並沒有提到「如何使用ember-data和rails在查詢中獲取多個寄存器」。只是我的觀點。 –
這是什麼工作:'App.Post.find({ids:[1,2,3]})'。有另一種方法嗎? –
'App.Store = DS.Store.extend({}); App.Store.findMany // undefined'。 –
商店是通過燼注入的,你不需要創建。你看過演示嗎? –
如何訪問它? –