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

Event persistence #17

Open
rosscado opened this issue Aug 16, 2018 · 3 comments
Open

Event persistence #17

rosscado opened this issue Aug 16, 2018 · 3 comments
Assignees

Comments

@rosscado
Copy link
Owner

Save resources to a backend database.

@rosscado rosscado self-assigned this Aug 16, 2018
@rosscado
Copy link
Owner Author

Accomplishments so far:

  • GET /events resources are retrieved from a persistent document store.
  • POST /events resources are attributed id attributes (transient).
  • Unit tests use a different (test_events) database to production (events).

@rosscado
Copy link
Owner Author

Single DB Instance

I only have a single Cloudant database instance available under the Lite/free plan.
I have bound the instance to the staging space app, leaving it unavailable to the production app. For this reason production can't be started for now.

Implement Transient Functionality First

I am pausing completion of the persistence feature until I have more functional work done first, specifically implementing event APIs #2

@rosscado rosscado changed the title Data persistence Event persistence Aug 24, 2018
@rosscado
Copy link
Owner Author

Entity Relationships

Our entity/resource documents will sometimes contain nested entities/resources that are best represented as their own documents, rather than embedded.

This article explains how to represent such a relationship in a Cloudant/CouchDB NoSQL database: https://wiki.apache.org/couchdb/EntityRelationship

Example (many:1 relationship)

Model:

---
_id: event_id
type: event
organising_club_id: club_id
---
_id: club_id
type: club

Client logic:

club = {'title': 'Little Club'}
club = db.create_document(club)
event = {'title': 'Big Race', 'organising_club_id': club['_id']}
event = db.create_document(event)

Views (1:many relationship)

No view is required for a 1:1 or many:1 relationship. Views are required for 1:many relationships.

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

No branches or pull requests

1 participant