Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database: Supports events #64

Merged
merged 1 commit into from
Apr 13, 2021
Merged

Database: Supports events #64

merged 1 commit into from
Apr 13, 2021

Conversation

kettanaito
Copy link
Member

@kettanaito kettanaito commented Apr 10, 2021

Changes

  • Adds a new public property "events" to the Database class.
  • Supports three main events:
    • create: when a new entity is created;
    • update: when an existing entity is updated;
    • delete: when an existing entity is deleted.

Motivation

By adding events to the Database, it becomes possible to listen to when they occur:

db.events.on('create', (modelName, prevEntity, nextEntity) => {
  console.log('created a new entity', modelName)
})

Persistency and synchronization would use database events to know when to apply them to other database instances (i.e. in other clients, or to the server instance).

@kettanaito kettanaito merged commit 89fa4a7 into master Apr 13, 2021
@kettanaito kettanaito deleted the db/events branch April 13, 2021 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant