donejs / donejs/demo-streaming-dev-server

Update to use a real database

Open
#1 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Currently the dev server serves data from a JSON file. To fully show off the capabilities of DoneJS' streaming technology it would be good to hook it up to a real database.

Steps:
* [x] - 1. Add PostgreSQL
* [x] - 2. Create a database and `todos` table
* [x] - 3. Change the server logic to use pull from the database

# Purpose

We want to build a server that acts as a simple file server, but also includes an `/api/todos` endpoint that delivers a streaming list of thousands of todos. This will show off how using streaming makes your application faster.

# Add PostgreSQL

[Postgre](https://www.postgresql.org/) is a SQL database widely used on the web and available as open source.

We want to make this project use a PostgreSQL database as its source for todos. Before doing anything else, check out a new branch to work on this:

```shell
git checkout -b postgre
```

When you are finished you will submit a pull request to get the changes into master.

Steps:
* [x] - 1. Figure out the best way to install Postgre. If everyone uses Macs then [Homebrew](https://brew.sh/) might be a good way to go.
* [x] - 2. Update the `README.md` file and include instructions
* [x] - 3. Submit a PR

# Create a database

We want a database where we can store todos.

Steps:
* [x] - 1. Create a database named `todos`. Create a table named `todos`. Probably we only need id and text fields.
* [x] - 2. Populate the todos with some random tasks. Let's go for 10,000 to start. Create a script or something that does this task for you and keep it in the repo so we can reuse it later if needed. The more meaningful sounding task the better, so if you can come up with something that generates random, but meaningful todos, that would be *awesome*.
* [x] - 3. Update the `README.md` to document the database layout. The db name, the table name and columns.
* [x] - 4. Submit a PR.

# Use the database

Change `server.js` to use PostgreSQL instead of the mock database it is currently using. [This code](https://github.com/donejs/demo-streaming-dev-server/blob/1e4b31bfffc61f836fde2c791867c709d5aba377/server.js#L12) is where we use the mock database.

Steps.
* [x] - 1. Find a package for connection to PostgreSQL from Node.
* [x] - 2. Update the server to use that database. Continue to use ndjson format so that each record is streamed as it is found in the database.
* [x] - 3. Submit a PR.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.