Getting the count of records in platform.api.get

Hi,

I’m trying to get the count of records from another table in a post trigger. I am using the example script merge_sql_nosql.js with V8js.
Unfortunately I can’t figure out how.

var result = platform.api.get(“mongodb/_table/posts”, params);
record.count= ???

Any help would be greatly appreciated.

Regards a new DF user.

Thanks

Hi @mrbijan,

You need include query string ?include_count=true in your request.

{
    "resource": [
        {
            "id": 352,
            ...
        },
        ...
    ],
    "meta": {
        "count": 8, <--- here
        "next": 1,
        "schema": {
            "name": "table_name",
            ...
        }
    }
}

This return contain meta.count with the number of registers.
Other possibility, to get only count with query string ?count_only=true

https://wiki.dreamfactory.com/DreamFactory/Features/Database/Records#Common_Parameters_and_Usage (see Selecting Returned Metadata section)

best regards,
Junior Conte

Using your post as inspiration I managed to fix it!
Thanks a lot!!