Skip to main content

Get Object

Get object

You can get an object by calling the get method. It gets the object identified by the id from the database.

info
  • If the id of the database object is not specified, it throws an exception.

  • If the database object identified with the id does not exist, it returns null.

// Gets the single record from employee collection where
// objectId equals to '62363a77b9a84d607cd78d7c'
let result = await altogic.db
.model("employee")
.object("62363a77b9a84d607cd78d7c")
.get();
Example response
{
"data": {
"name": "Rooby the Robot",
"mail": "[email protected]",
"title": "Robot",
"hireDate": "2019-10-10T10:00:00.000Z",
"birthDate": "1999-10-10T10:00:00.000Z",
"_id": "62363a77b9a84d607cd78d7c",
"department": {
"_id": "62363a77b9a84d607cd78d7d",
"_parent": "62363a77b9a84d607cd78d7c",
"name": "Robot Office",
"code": 31415
}
},
"errors": null
}
note

If the client library key is set to enforce session, an active user session is required (e.g., user needs to be logged in) to call this method.

Parameters

Here you can find parameters for the get method.

#

Name

Data type

Required

Description

1optionsGetOptionsNoDefines the options for an object query operation. By default no caching of the retrieved object in Redis store.

GetOptions properties

Here you can find properties for the GetOptions

#

Name

Data type

Description

1cacheStringSpecify whether to cache the retrieved object using its id as the cache key or not.
If the object is cached and the timeout has expired, the cached object will automatically be removed from the cache.
It can be nocache noexpiry 30sec 1min 2mins 5mins 10mins 15mins 30mins 1hour 6hours 12hours 1day 1week 1month 6months 1year