Browse files

Updated RPC doc with ss.apiadd() example

  • Loading branch information...
1 parent a6d1051 commit 62afedc403a40e85e14576b12e35fa0d7e30d2f6 Owen Barnes committed Aug 5, 2012
Showing with 16 additions and 0 deletions.
  1. +16 −0 doc/guide/en/
@@ -77,6 +77,22 @@ ss.rpc('products.add', 123, function(err, data){
You may pass as many arguments as you want - just remember the last argument should always be the callback if you're expecting a response from the server.
+### How can I call a Mongoose/Redis/DB/REST API from my RPC actions?
+Require the module you need in your main `/app.js` file then add it to the 'internal API':
+// in /app.js
+var db = require('mydb');
+var conn = db.createConnection();
+ss.api.add('db', conn);
+You may now access this DB connection in your `/server/rpc` methods with `ss.db`.
### How does it work under the hood?
The RPC Responder serializes messages in both directions using JSON. Thus the actual message sent over the wire is a string which looks like this:

0 comments on commit 62afedc

Please sign in to comment.