Skip to main content
Version: Previous

Quick start - add business logic

So far, you have a table; now we want to be able to see its content and create new entries.

Data Server

A Data Server provides real-time data to the front end. It also creates an HTTP endpoint that can be accessed by any client. You must define the Data Server in the file alpha-dataserver.kts. This file is under server/alpha-app/src/main/genesis/scripts.

dataServer {
query("ALL_TRADES", TRADE)
}

Event Handler

Next, we want to be able to insert rows into our table. For this, you need to define an Event Handler in the file alpha-eventhandler.kts. This file is under server/alpha-app/src/main/genesis/scripts.

eventHandler {

eventHandler<Trade>(name = "TRADE_INSERT") {
onCommit { event ->
entityDb.insert(event.details)
ack()
}
}

}

In this example, we use a database interface called entityDb. For more information about it, follow this link.