Skip to content

Instantly share code, notes, and snippets.

@DennisAlund
Last active December 6, 2016 06:07
Show Gist options
  • Select an option

  • Save DennisAlund/b841d8c0d6e95daae5319670896d7545 to your computer and use it in GitHub Desktop.

Select an option

Save DennisAlund/b841d8c0d6e95daae5319670896d7545 to your computer and use it in GitHub Desktop.
path /visits/{visit_id} is Visit {
read() { canManageBusiness(this.businessId) }
write() { canManageBusiness(this.businessId) }
}
path /businessVisits/{business_id}/{visit_id} is Visit {
read() { canManageBusiness(business_id) }
}
path /memberVisits/{member_id}/{visit_id} is Visit {
read() { canManageBusiness(this.businessId) }
}
type Visit {
duration: UnsignedNumber | Null,
in: UnsignedNumber,
memberId: String,
out: UnsignedNumber | Null,
businessId: String,
validate() {
(this.out === null || this.duration === (this.out - this.in))
}
}
type UnsignedNumber extends Number {
validate() { this >= 0 }
}
isSignedIn() { auth !== null }
isCurrentUser(uid) { isSignedIn() && auth.uid === uid }
canManageBusiness(id) {
// Check that the user has proper credentials in your own logic
isSignedIn()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment