Custom Entity
Custom Entities are very similar to Global Entities, but with several advanced features that make them more applicable for larger data sets.
Like Global Entities, Custom Entites are:
- available across all users of an app
- access is controlled via ACL
- have an
entityType
for organization - can have
owners
or be un-owned (as system objects) - can be automatically deleted via TTL (time-to-live)
Custom Entities differ in these ways:
- You must pre-declare your
entityTypes
ahead-of-time - You can create custom indexes for each
entityType
for fast lookups - You can have an unlimited # of custom entities
- You can do partial updates of custom entities
- Custom entities support auto-migration during deployment
Custom Entities supports text
index, $text
operator can be use to query document fields once a text
index is set up. Note that as the MongoDB restriction, one collection can have only one text
index.
{
"entityType": "questions",
"context": {
"pagination": {
"rowsPerPage": 50,
"pageNumber": 1
},
"searchCriteria": {
"$text":{"$search": "moon"}
},
"sortCriteria": {
"createdAt": 1
}
}
}
Custom Entities are a premium feature available to Plus Plan customers. Additional usage fees apply.
API Summary
Basic Access
- CreateEntity - Creates new custom entity.
- DeleteEntity - Deletes the specified custom entity on the server.
- DeleteEntities - Deletes all applicable custom entities from the server based on the custom entity type and specified delete criteria.
- DeleteSingleton - Deletes the specified custom entity singleton, owned by the session's user, for the specified entity type, on the server.
- IncrementData - Increments the specified fields by the specified amount within custom entity data on the server.
- IncrementDataSharded - Increments the specified fields by the specified amount within custom entity data on the server, enforcing ownership/ACL permissions.
- IncrementSingletonData - Increments the specified fields, of the singleton owned by the user, by the specified amount within the custom entity data on the server.
- ReadEntity - Reads a custom entity.
- ReadSingleton - Reads the custom entity singleton owned by the session's user.
- UpdateEntity - Replaces the specified custom entity's data, and optionally updates the acl and expiry, on the server.
- UpdateEntityFields - Sets the specified fields within custom entity data on the server.
- UpdateEntityFieldsSharded - For sharded custom collection entities. Sets the specified fields within custom entity data on the server, enforcing ownership/ACL permissions.
- UpdateSingleton - Updates the singleton owned by the user for the specified custom entity type on the server, creating the singleton if it does not exist. This operation results in the owned singleton's data being completely replaced by the passed in JSON object.
- UpdateSingletonFields - Partially updates the data, of the singleton owned by the user for the specified custom entity type, with the specified fields, on the server.
Paging
- GetCount - Counts the number of custom entities meeting the specified where clause.
- GetEntityPage - Retrieves first page of custom entities from the server based on the custom entity type and specified query context.
- GetEntityPageOffset - Gets the page of custom entities from the server based on the encoded context and specified page offset.
- GetRandomEntitiesMatching - Gets a list of up to maxReturn randomly selected custom entities from the server based on the entity type and where condition.
Bypassing ACL for System Objects
- SysCreateEntity - Creates new custom entity.
- SysDeleteEntity - Deletes the specified custom entity on the server.
- SysDeleteEntities - Deletes all applicable custom entities from the server based on the custom entity type, specified delete criteria and acrossAllUsers flag.
- SysGetCount - Counts the number of custom entities meeting the specified where clause.
- SysGetEntityPage - Retrieves first page of custom entities from the server based on the custom entity type and specified query context
- SysGetEntityPageOffset - Gets the page of custom entities from the server based on the encoded context and specified page offset.
- SysGetRandomEntitiesMatching - Gets a list of up to maxReturn randomly selected custom entities from the server based on the entity type and where condition, bypassing ownership/ACL permissions checking.
- SysIncrementData - Increments the specified fields by the specified amount within custom entity data on the server.
- SysIncrementData - Increments the specified fields by the specified amount within custom entity data on the server, bypassing ownership/ACL permissions checks.
- SysIncrementDataSharded - Increments the specified fields by the specified amount within custom entity data on the server, bypassing ownership/ACL permissions.
- SysReadEntity - Reads a custom entity.
- SysUpdateEntity - Replaces the specified custom entity's data, and optionally updates the acl and expiry, on the server.
- SysUpdateEntityFields - Sets the specified fields within custom entity data on the server.
- SysUpdateEntityFieldsSharded - For sharded custom collection entities. Sets the specified fields within custom entity data on the server, bypassing ACL permissions checks.
- SysUpdateEntityOwner - Updates the owner of the custom entity.
Schema Management
- SysCreateCollection - Creates configuration for new custom entity collection.
- SysCreateIndex - Creates a new index on a custom entity collection.
- SysDropCollection - Drops the specified custom entity collection.
- SysDropIndex - Drops the specified index from the identified custom entity collection.
- SysListCollections - Lists the custom entity collections configured for the application.
- SysListIndexes - Retrieves list of indexes configured for a custom entity collection.
- SysUpdateCollectionMigrate - Updates the migration flag for the custom entity collection.
📄️ CreateEntity
Creates a new custom entity.
📄️ DeleteEntities
Deletes all applicable custom entities from the server based on the custom entity type and specified delete criteria, enforcing ownership/ACL permissions.
📄️ DeleteEntity
Deletes the specified custom entity on the server.
📄️ DeleteSingleton
Deletes the specified custom entity singleton, owned by the session's user, for the specified entity type, on the server.
📄️ GetCount
Counts the number of custom entities meeting the specified where clause.
📄️ GetEntityPage
Retrieves the first page of custom entities from the server based on the custom entity type and specified query context.
📄️ GetEntityPageOffset
Gets the page of custom entities from the server based on the encoded context and specified page offset.
📄️ GetRandomEntitiesMatching
Gets a list of up to maxReturn randomly selected custom entities from the server based on the entity type and where condition.
📄️ IncrementData
This method is not sharding safe - and thus is not recommended for custom entities that you may want to shard for greater performance and scalability in the future.
📄️ IncrementDataSharded
Increments the specified fields by the specified amount within custom entity data on the server, enforcing ownership/ACL permissions.
📄️ IncrementSingletonData
Increments the specified fields, of the singleton owned by the user, by the specified amount within the custom entity data on the server.
📄️ ReadEntity
Reads a custom entity.
📄️ ReadSingleton
Reads the custom entity singleton owned by the session's user.
📄️ SysCreateCollection
Creates configuration for new custom entity collection.
📄️ SysCreateEntity
Advanced version of createEntity that allows a specific user to be specified as owner (or none). Also callable from S2S sessions.
📄️ SysCreateIndex
Creates a new index on a custom entity collection.
📄️ SysDeleteEntities
Deletes all applicable custom entities from the server based on the custom entity type, specified delete criteria and acrossAllUsers flag, bypassing ownership/ACL checks.
📄️ SysDeleteEntity
Advanced version of deleteEntity that bypasses the ACL check. Available from S2S sessions.
📄️ SysDropCollection
Drops the specified entity type collection.
📄️ SysDropIndex
Drops the specified index from the identified custom entity collection.
📄️ SysDropIndexNamed
Drops the specified index from the identified custom entity collection.
📄️ SysGetCount
Counts the number of custom entities meeting the specified where clause.
📄️ SysGetEntityPage
Retrieves first page of custom entities from the server based on the custom entity type and specified query context. Bypasses ownership/ACL checks.
📄️ SysGetEntityPageOffset
Gets the page of custom entities from the server based on the encoded context and specified page offset. Bypasses ownership/ACL checks.
📄️ SysGetRandomEntitiesMatching
Gets a list of up to maxReturn randomly selected custom entities from the server based on the entity type and where condition, bypassing ownership/ACL permissions checking.
📄️ SysIncrementData
This method is not sharding safe - and thus is not recommended for custom entities that you may want to shard for greater performance and scalability in the future.
📄️ SysIncrementDataSharded
Increments the specified fields by the specified amount within custom entity data on the server, bypassing ownership/ACL permissions.
📄️ SysListCollections
Lists the custom entity collections configured for the application.
📄️ SysListIndexes
Retrieves list of indexes configured for a custom entity collection.
📄️ SysReadEntity
Reads a custom entity. Ignores ownership/ACL checks.
📄️ SysUpdateCollectionMigrate
Updates the collection option indicating whether custom collection data is to be migrated during deployment (true) or not (false).
📄️ SysUpdateCollectionOptions
Updates the collection options for the custom collection.
📄️ SysUpdateEntity
Replaces the specified custom entity's data, and optionally updates the acl and expiry, on the server. Ignores ownership/ACL checks.
📄️ SysUpdateEntityFields
This method is not sharding safe - and thus is not recommended for custom entities that you may want to shard for greater performance and scalability in the future.
📄️ SysUpdateEntityFieldsSharded
For sharded custom collection entities. Sets the specified fields within custom entity data on the server, bypassing ACL permissions checks.
📄️ SysUpdateEntityOwner
Updates the owner of the specified custom entity.
📄️ UpdateEntity
Replaces the specified custom entity's data, and optionally updates the acl and expiry, on the server.
📄️ UpdateEntityFields
This method is not sharding safe - and thus is not recommended for custom entities that you may want to shard for greater performance and scalability in the future.
📄️ UpdateEntityFieldsSharded
For sharded custom collection entities. Sets the specified fields within custom entity data on the server, enforcing ownership/ACL permissions.
📄️ UpdateSingleton
Updates the singleton owned by the user for the specified custom entity type on the server, creating the singleton if it does not exist. This operation results in the owned singleton's data being completely replaced by the passed in JSON object.
📄️ UpdateSingletonFields
Partially updates the data, of the singleton owned by the user for the specified custom entity type, with the specified fields, on the server.