Version: 1.0.0
This library allows your agent code to work with the MongoDB Stitch service.
This version of the library supports the following functionality:
You can view the library’s source code on GitHub. Click here to see information on the available versions of this library.
To include this library in your project, add
#require "MongoDBStitch.agent.lib.nut:1.0.0"
at the top of your agent code.
Before using the library you need to have:
All requests that are made to the MongoDB Stitch service occur asynchronously. Every method that sends a request has an optional parameter which takes a callback function that will be executed when the operation is completed, whether successfully or not. The callbacks’ parameters are listed in the corresponding method description, but every callback has at least one parameter, error. If error is null
, the operation has been executed successfully. Otherwise, error is an instance of the MongoDBStitchError class and contains the details of the error.
Parameter | Data Type | Required? | Description |
---|---|---|---|
appId | String | Yes | The Stitch application’s ID |
This method returns a new MongoDBStitch instance.
This method logs the agent into to the Stitch application. Authentication is by API key and is required every time the library is restarted.
Parameter | Data Type | Required? | Description |
---|---|---|---|
apiKey | String | Yes | The Stitch application’s API key |
callback | Function | Optional | Executed once the operation is completed |
This method returns nothing. The result of the operation may be obtained via the callback function, which has the following parameters:
Parameter | Data Type | Description |
---|---|---|
error | MongoDBStitchError | Error details, or null if the operation succeeds |
response | Table | The body of the HTTP response received from the MongoDB Stitch service after it has been decoded from JSON into a table. The table’s keys are strings; their values may be any type |
This method executes the specified MongoDB Function. The Function should already exist in the Stitch application.
Parameter | Data Type | Required? | Description |
---|---|---|---|
name | String | Yes | The name of the Function |
args | Array of any type | Optional | Input parameters for the Function |
callback | Function | Optional | Executed once the operation is completed |
This method returns nothing. The result of the operation may be obtained via the callback function, which has the following parameters:
Parameter | Data Type | Description |
---|---|---|
error | MongoDBStitchError | Error details, or null if the operation succeeds |
response | Table | The body of the HTTP response received from the MongoDB Stitch service after it has been decoded from JSON into a table. The table’s keys are strings; their values may be any type |
This method enables (value is true
) or disables (value is false
) the library debug output (including error logging). It is disabled by default. The method returns nothing.
This class represents an error returned by the library and has the following public properties:
null
if type is MONGO_DB_STITCH_ERROR.LIBRARY_ERRORnull
if type is MONGO_DB_STITCH_ERROR.LIBRARY_ERROR.Working examples are provided in the Examples.
The Electric Imp Dev Center documents the latest version of the library. For past versions, please see the Electric Imp public GitHub repos listed below.
Version | Source Code | Notes |
---|---|---|
1.0.0 | GitHub | Initial release |
The MongoDBStitch library is licensed under the MIT License.