Skip to content

Instantly share code, notes, and snippets.

@jeroenr
Last active July 8, 2021 19:12
Show Gist options
  • Save jeroenr/64a30d1112dd2b89190cb8b6f7c27afa to your computer and use it in GitHub Desktop.
Save jeroenr/64a30d1112dd2b89190cb8b6f7c27afa to your computer and use it in GitHub Desktop.
Entity example
@Document
data class UserAccount(
@Id
val _id: ObjectId = ObjectId(),
var name: String,
var createdAt: Instant = Instant.now(),
var updatedAt: Instant = Instant.now()
) {
var auditTrail: List<String> = listOf()
fun updateName(name: String) {
this.auditTrail = auditTrail.plus(
“${this.name} -> ${name}”
)
this.name = name
this.updatedAt = Instant.now()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment