The developer platform offers two types of data stores - a key-value store (KV store) and an entity store - to persist and use data across the lifecycle of an app. The data stores are accessible through run-time interfaces.
The KV store allows you to store data as keys with a corresponding value of limited size. Each key is a string and each value a valid JSON object. It does not require any schema to be declared ahead of time. The KV store is ideal for storing app data, where the developer knows the keys at query time, thereby enabling a lookup operation against the store. For example, the number of times an agent views a specific ticket, is app data that is a candidate for KV store. Limitations: It does not allow querying for a select range or pattern of keys. It is not ideal for storing records of the same type that need querying based on field values or where the size of the value could be larger than 32 KB. Such a scenario will require the developer to implement custom logic on top of the KV store to store the data efficiently, build an index, and query the data at runtime.
Entity store requires you to declare an entity schema as a configuration. You can then create and manipulate records of the same type in the app code. This approach is practical when a predictable data structure can be planned ahead of time, for your app requirements. You can think of it like a light-weight SQL-like persistence store but not as powerful as a raw SQL-DB. An entity store is ideal for querying/filtering/listing use-cases.
SQL databases need developers to define a table schema before adding rows to the table and allow manipulating data, using a DSL (SQL). Similarly, Entity store requires you to define an entity schema before you add records for that entity and allows querying the records using a set of query parameters. The similarity ends here. An SQL database does a lot more. It is often run as an additional service, not embedded in the application, and needs extra maintenance. Most importantly, it gives SQL as a rich DSL to query pretty much anything stored in the database.
To use an SQL database from a Freshworks app you must maintain the database on external infrastructure. You can then choose to expose the database directly over the internet (not recommended) or write a server application that talks to the database and exposes an HTTP API over the internet (works, but takes more effort).
The Entity store does not require you to build and maintain any external services for your app’s storage needs. The Entity store’s run-time APIs provide methods to perform create, retrieve, update, and delete (CRUD) operations on records.
This section,
- Details how to use run-time interfaces to access the KV store or Entity store.
- Acts as a reference to all the methods and options available as part of these interfaces.