我想扩展模型的查询方法,这就是我写的:
store.query.expose('todos', 'forGroup', function(group) {
return this.where('group').equals(group);
});
但是当我运行应用程序时,控制台说“无法调用未定义的方法公开”,这意味着store.query未定义。为什么?
商店变量是:
var store = derby.createStore({
db: liveDbMongo(mongoUrl + '?auto_reconnect', {safe: true})
, redis: redis
});
我还使用console.log输出商店:
{ domain: null,
_events: { client: [Function] },
_maxListeners: 10,
racer:
{ get: [Function],
_plugins: [ [Function: derbyServer] ],
run: [Function: run],
createApp: [Function: createApp],
createStatic: [Function: createStatic] },
modelOptions: undefined,
shareClient:
{ options: { db: [Object], redis: [Object] },
preValidate: undefined,
validate: undefined,
backend:
{ snapshotDb: [Object],
getOps: [Function],
publish: [Function],
submit: [Function],
_subscribeChannels: [Function],
subscribe: [Function],
fetch: [Function],
bulkFetchCached: [Function],
fetchAndSubscribe: [Function],
queryFetch: [Function],
query: [Function],
collection: [Function],
destroy: [Function] },
extensions: { '': [] },
docFilters: [],
opFilters: [] },
logger: undefined }
和console.log(store.query)
输出undefined
。
答案 0 :(得分:1)
访问控制Api在0.5版Racer中已更改,此处提到http://blog.derbyjs.com/2013/06/04/migrating-from-derby-0-dot-3-to-0-dot-5/
我没有在认证方面玩过那么多,但是指针是要查看GitHub上的Auth示例 - https://github.com/codeparty/derby-examples/tree/master/auth。