oscarb pad

Guides, resources, notes, docs and knowledge for everything Oscar.

Tags

Parse server

Install

Windows

npm install -g parse-server mongodb-runner

If MongoDb fails, download MongoDb.

MongoDb

Start database

"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --dbpath "d:\test\mongo db data"

Connect to MongoDb

"C:\Program Files\MongoDB\Server\3.4\bin\mongo.exe

Resources

Relationships

Referencing on the one-side, many-side or both?

Denormalize fields into the one or many side
Updating denormalized values are slower, more expensive and not atomic.

  1. Favor embedding unless there is a compelling reason not to
  2. Needing access to an object on its own is reason not to embed it
  3. Arrays should not grow without a bond. Don’t embed if there are more than hundreds on the many side. IF there are thousands on the many side, don’t use an array of pointers.
  4. Use application-level joins as they are barely more expensive than server-side joins in relational databases.
  5. Consider write/read ratio when denomralizing. Fields that are only read but rarely updated to are good candidates for denormalization.
  6. Structure the data to match the ways the application queries and updates it.

Two-way referencing

One-to-one

Embedded vs referencing

Embedding is better for…

Small subdocuments
Data that does not change regularly
When eventual consistency is acceptable
Documents that grow by a small amount
Data that you’ll often need to perform a second query to fetch Fast reads
References are better for…

Large subdocuments
Volatile data
When immediate consistency is necessary
Documents that grow a large amount
Data that you’ll often exclude from the results
Fast writes

https://stackoverflow.com/a/27247579/6131896

One-to-many

A blog post has many comments
A comment can only belong to one blog post
Customer has many orders

Should the objects on the many side be accessed separately or only in the context of the parent object?

What is the ratio of updates to reads for a particular field?

One-to-few

Array of embedded documents

< 100 documents

One-to-many

Array of pointers or part-reference on the many-side

> 100 documents

One-to-squillions

Use parent-reference on the many-side

Pointers

Comment

Query for all comments…
“Get all comments where post is blog post X”

Query for post that a comment belongs to

Arrays

BlogPost

Query for all comments

Query for blog post that comment belongs to

Many-to-many

Users following each other
Students and teachers
Sales persons and Accounts

If the relationships requires meta-data, use join tables otherwise Parse Relation

Parse Relation

Create…

Query all accounts for a gien person

Query all persons for a given account

Join Table

When meta-data is required for the relationships

Users following users

Creating…

Querying does Bob follow Eve…

Hosting

Parse/Node

Name Database storage Requests/second Price Notes
Back4App 0.5 GB 10 Free 1 Cloud code job
Buddy ? 30 Free $100 USD per additional 10 rps per month
Heroku 10K rows ? Free -
Google Cloud Platform ? ? ? -
Red Hat OpenShift Online 1GiB 1GiB Memory Free -

MongoDb

Name Database storage Price Notes
mLab 0.5 GB Free -

Push notifications

Back4App

CLI

Command Description
configure accountkey Configure account to use
new Create a new app or add cloud code to an existing app
deplpy Deploy code
list View all linked apps
develop <App Name> Watch for any updates, deploy them and see live stream of Cloud Code logs.

Resources

How-to