# MongoDB Triggers
## Names
| action number | description |
| ------------- | ----------- |
| 2 | Create
| 3 | Update
| 4 | Delete
Trigger name template: \<collectionName>\_action(?\_action)_\<event>
Example:
```entities_2_3_systemUser``` - Trigger subscribed on collection entities on actions: create, update. And handler works with system users
## Code template
```
const nodeEnv = 'uat';
const dbName = "Rake-System-UAT";
exports = async function(changeEvent) {
const systemConfigCollection = context.services.get("UAT").db(dbName).collection("systemConfigs");
const entitiesCollection = context.services.get("UAT").db(dbName).collection("entities");
const [config] = await systemConfigCollection.find({ nodeEnv }).toArray();
const [entity] = await entitiesCollection.find({ entityId: changeEvent.fullDocument.entityId }).toArray();
const coreUrl = config.serverUrl;
const workspaceId = config.workspaceId;
const hash = config.hash;
const doc = {
systemUserId: changeEvent.fullDocument.systemUserId,
email: changeEvent.fullDocument.email,
firstName: entity.firstName,
lastName: entity.lastName,
phoneNumber: entity.phoneNumber
};
const systemEventId = changeEvent.operationType === 'INSERT' ? -140 : -139;
const options = {
url: `${coreUrl}/workspaces/${workspaceId}/system-events`,
headers: { authorization: [hash] },
body: JSON.stringify({ systemEventId, data: doc }),
};
return context.http.post(options);
};
```
## hub-spot events
### List of triggers
| systemEventIds | name | description |
| -------------- | ---- | ----------- |
| -139 | entities_3_systemUser | create system event about updating system user information in entities collection
| -140, -139 | systemUser_2_3_systemUser | create system event about updating or creating system user in systemUsers collection
| -137, -138, -141| workspaces_2_3_workspace | create system event avout updating or creating workspace in workspaces collection