Search code examples
javascriptmeteorbackendddp

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!


Solution

  • 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: "[email protected]"}

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

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