简体   繁体   English

流星使用DDP将数据从客户端推送到服务器

[英]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. 我打算为强类型的数据驱动后端平台编写流星/ DDP服务器。 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. 阅读DDP文档后 ,该协议似乎仅支持客户端对数据的订阅。 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.". 该文档指出DDP支持“客户端到服务器的远程过程调用”。 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. 我想我可以定义C(R)UD过程以将修改推回服务器,但是我恐怕会偏离本机Meteor体验。

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 . 当您运行insertupdateremoveupsert操作时,这实际上会触发method The DDP protocol doesn't directly take CRUD operations. DDP协议不会直接执行CRUD操作。

The method names would be as follows for an insert into a collection called 'mycollection' 对于插入名为“ mycollection”的集合的方法名称如下所示

Method name : /mycollection/insert 方法名称: /mycollection/insert

the params would be the document itself as the first parameter with an optional randomSeed parameter. 参数将是文档本身,作为带有可选的randomSeed参数的第一个参数。

Example JSON to insert a document { name: "bob", email: "bob@bob.bob"} 用于插入文档的示例JSON { 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. 同样地, update使用update ,而不是insert的路径,即/mycollection/update在两个参数给出了一个可选的包含第三选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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