Skip to content

Instantly share code, notes, and snippets.

@1dolinski
Last active August 31, 2016 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1dolinski/901f063464be66f8e37fc59bdc66903e to your computer and use it in GitHub Desktop.
Save 1dolinski/901f063464be66f8e37fc59bdc66903e to your computer and use it in GitHub Desktop.
// 1. data modelling and joins?
// allows for querying orders
// requires getting activites and then querying orders
// little slower on the reads?? -- read activity and then read async value details
// can easily read orders?
// a.
// please note that there could be multiple types
x = {
activities: {
'uid': {
'-pushid1': { // pushid
createdAt: 1231832789,
total: 2000,
type: 'orders',
details: {
'-k3vsdf23iouv': true,
'-k52vsdf23iouk': true
}
},
},
orders: {
'uid': {
'-k3vsdf23iouv': {
price: 1000,
name: 'Big Mac',
activities: {
'-pushid1': true
}
},
'-k52vsdf23iouk': {
price: 1000,
name: 'Frosty',
activities: {
'-pushid1': true
}
}
}
}
}
}
// b.
// faster reads, only 1 read needed!
// less flexibility, less ability to query orders individually
y = {
activities: {
$pushid: {
createdAt: 1231832789,
total: 2000,
orders: {
'-k3vsdf23iouv': { price: 1000, name: 'Big Mac' },
'k52vsdf23iouk': { price: 1000, name: 'Frosty '}
}
}
}
// a. pushed objects
// not sure how to query for both uid AND startDate
// easy to achieve goal 2
// merely for finding the last 100 activities or so
z = {
activities: {
pushid: {
startDate: 123456,
createdAt: 1231832789,
uid: '-k23v39vxoqlknv9'
}
}
}
// b. uid with pushed objects
// faster reads for a user
// easy to achieve goal 1
// not sure how to achieve goal 2 when multiple users are included
// details show in user Activities
a = {
userActivities: {
'-k23v39vxoqlknv9': { // this is the $uid
pushid: {
startDate: 123456
createdAt: 1231832789
property1: 'hamburger',
property2: 'lunch',
property3: 'starving',
property4: 'weightIsNotAnIssue',
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment