我想使用 RacerJs/DerbyJs 将项目添加到集合中,但它不起作用。我一定是真的忽略了什么……
我试过的
model.set('news', [
{ text: "something" }
]);
这确实设置了一个新闻项目。但是,当我再次这样做时,它只会覆盖现有项目,而不是添加新项目。怎么做?
model.push('news', {text:"someText"})
也因“对象不是数组”而失败。
基本上,我只想要“发布更新并在‘墙’应用程序上显示”的最基本版本,没有任何房间,也没有使用数组。只有一个集合,就是这样。
变体的堆栈跟踪.push()
:
2013 年 5 月 22 日星期三 09:35:24 GMT+0200(西欧夏令时间)(23168) d7564d2d-f23 8-4ce0-a0a2-6e376e9b5cb1 ?版本:0 - 推送“新闻”,{文本:“adsf”} C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\ 内存.js:185 throw new TypeError(arr + ' is not an Array'); ^ 类型错误:[object Object] 不是数组 在 Object.arrayLookupSet [as _arrayLookupSet] (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\Memory.js:185:11) 在 Object.applyArrayMethod [as _applyArrayMethod] (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\Memory.js:145:18) 在 Object.push (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\Memory.js:118:15) 在 applyTxn (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\transaction.js:114:32) 在 Object.exports.applyTxnToDoc (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\transaction.js:126:3) 在 Function.QueryInterface.publish (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\adapters\pubsub-memory\channel-interface-query.js:25:24) 在 PubSub.publish (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\pubSub\PubSub.js:63:10) 在 Store.module.exports.proto.publish (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\pubSub\pubSub.Store.js:174:20) 在发布时(C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\txns\txns.Store.js:230:15) 在下一个(C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\middleware.js:7:26) 在 module.exports.events.middleware.txn (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\txns\txns.Store.js:220:11) 在 Store._sendToDb.lockingDone (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\Store.js:294:12) 在 mergeAll.setupRoutes (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\adapters\db-memory\index.js:70:13) 在 DbMemory.mergeAll.get (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\adapters\db-memory\index.js:44:5) 在 mergeAll.setupRoutes (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\adapters\db-memory\index.js:62:16) 在 DbMemory.mergeAll.get (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\adapters\db-memory\index.js:44:5) 在 mergeAll.setupRoutes (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\adapters\db-memory\index.js:60:14) 在下一个(C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\Store.js:321:15) 在 Store._sendToDb (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\Store.js:324:10) 在 writeToDb (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\txns\txns.Store.js:216:15) 在下一个(C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\middleware.js:7:26) 在 serialEmitPrep (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\txns\txns.Store.js:125:9) 在下一个(C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\middleware.js:7:26) 在 incrVer (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\modes\lww.js:18:12) 在下一个(C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\middleware.js:7:26) 在 Object.module.exports.events.init.store.eachContext.context.guardWrite (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\accessControl\accessControl.Store.js: 54:51) 在 accessController (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\txns\txns.Store.js:103:17) 在下一个(C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\middleware.js:7:26) 在 Object.run (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\middleware.js:10:12) 在 Socket.module.exports.events.socket (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\txns\txns.Store.js:267:26) 在 Socket.racer.log.sockets.sockets.on.socket.on (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\lib\log.server.js:150:20) 在 Socket.EventEmitter.emit [as $emit] (events.js:91:17) 在 SocketNamespace.handlePacket (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\node_modules\socket.io\lib\namespace.js:335:22) 在 Manager.onClientMessage (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\node_modules\socket.io\lib\manager.js:488:38) 在 WebSocket.Transport.onMessage (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\node_modules\socket.io\lib\transport.js:387:20) 在解析器。(C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\node_modules\socket.io\lib\transports\websocket\hybi-16.js:39:10) 在 Parser.EventEmitter.emit (events.js:88:17) 在 opcodeHandlers.1.finish (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\node_modules\socket.io\lib\transports\websocket\hybi-16.js:288:16) 在 Parser.opcodeHandlers.1.expectData [as expectHandler] (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\node_modules\socket.io\lib\transports\websocket\hybi-16. js:299:15) 在 Parser.add (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\node_modules\socket.io\lib\transports\websocket\hybi-16.js:466:24) 在 Parser.expect (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\node_modules\socket.io\lib\transports\websocket\hybi-16.js:499:10) 在 Parser.opcodeHandlers.1.expectData (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\node_modules\socket.io\lib\transports\websocket\hybi-16.js:298: 18) 在 Parser.add (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\node_modules\socket.io\lib\transports\websocket\hybi-16.js:466:24) 在 Parser.expect (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\node_modules\socket.io\lib\transports\websocket\hybi-16.js:499:10) 在 opcodeHandlers.1.expectData (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\node_modules\socket.io\lib\transports\websocket\hybi-16.js:296:16) 在 opcodeHandlers.1 (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\node_modules\socket.io\lib\transports\websocket\hybi-16.js:313:9) 在 Parser.processPacket (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\node_modules\socket.io\lib\transports\websocket\hybi-16.js:533:8) 在 Parser.add (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\node_modules\socket.io\lib\transports\websocket\hybi-16.js:466:24) 在 Socket.WebSocket.onSocketConnect (C:\xampp\htdocs\Derbyjs\KnowEdge\app1\node_modules\derby\node_modules\racer\node_modules\socket.io\lib\transports\websocket\hybi-16.js:141:17) 在 Socket.EventEmitter.emit (events.js:88:17) 在 TCP.onread (net.js:396:14)