简体   繁体   中英

Meteor pushing data from client to server using DDP

I am planning to write a meteor/DDP server for a strongly typed, data-driven backend platform. The server must be able to both push data to, and accept data from a client.

After reading the DDP documentation it seems the protocol only supports client-side subscriptions on data. From the document, I don't see how meteor pushes data back from a client to a server.

The document states DDP supports "Remote procedure calls by the client to the server.". I suppose I could define C(R)UD procedures for pushing modifications back to the server, but I'm afraid I'd deviate from the native Meteor experience.

Any suggestions are appreciated!

Ah yes this is probably less clear.

When you run a insert , update , remove or upsert operation this actually triggers method . The DDP protocol doesn't directly take CRUD operations.

The method names would be as follows for an insert into a collection called 'mycollection'

Method name : /mycollection/insert

the params would be the document itself as the first parameter with an optional randomSeed parameter.

Example JSON to insert a document { name: "bob", email: "bob@bob.bob"}

{"msg":"method","method":"/mycollection/insert","params":[{ _id:"123456", name: "bob", email: "bob@bob.bob"}],"id":"1"}

Likewise, update using update instead of insert in the path, ie /mycollection/update gives in two params with an optional third containing options.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM