getSelectResult(mongoDBInstance: Db instance, index: String, query: Object, page: Object)
[starting from version: 2.8]
This API call allows getting the data from a MongoDB database. Used in the handler of the Flexmonster /select
request. The getSelectResult
method is a part of the Flexmonster MongoDB Connector API.
Parameter/Type | Description |
---|---|
mongoDBInstance Db instance |
The instance of the needed MongoDB database. |
index String |
The collection’s name. index is sent in the body of the Flexmonster request. |
query Object |
query is sent in the body of the Flexmonster request. |
page Object |
Can be used to load members by parts. |
page.pageNumber Number |
Page number. Starts from 0 . pageNumber is sent in the body of the Flexmonster request. |
page.pageToken String |
A key calculated on the server that defines which part of the data should be loaded next. pageToken is sent in the body of the Flexmonster request. |
Array of objects, which contains the aggregated data. The response format for compact and classic tables is the same as in the /select request for the pivot table. The response for the flat table corresponds to the response of the /select request for the flat table.
mongo.post("/select", async (req, res) => { try { const result = await MongoDataAPI.getSelectResult(mongoDBInstance, req.body.index, req.body.query,{ page: req.body.page, pageToken: req.body.pageToken }); res.json(result); } catch (err) { } });