Skip to content

Instantly share code, notes, and snippets.

// 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: {
// Goal1: get activites for user for particular date
// Goal2: get most recent activites in the database for reporting
// Match: UID and startDate
// 2 options
// a. pushed objects
// not sure how to query for both uid AND startDate
// easy to achieve goal 2
z = {
"users": {
"$uid": {
".read": "auth !== null && (auth.uid === $uid || auth.uid === 'admin')",
".write": "auth !== null && newData.child('email').exists() && (auth.uid === $uid || auth.uid === 'admin')",
// https://medium.com/@koresar/fun-with-stamps-episode-1-stamp-basics-e0627d81efe0#.ke7jo334j
const stampit = require('stampit');
// stampit(methods, state, enclose);
const HasFoo = stampit.compose({
properties: {
foo: 'default foo!'
}
});
const stampit = require('stampit');
// stampit(methods, state, enclose);
var testObj = stampit(
// methods
{
delegateMethod: function delegateMethod() {
return 'shared property';
}
},
var stripe = require("stripe")(
"TEST_STRIPE_HERE"
);
class Charge {
constructor(opts = {}) {
this.amount = opts.amount;
this.currency = 'cad';
this.customer = opts.customer;
this.description = opts.description;
const stripeProvider = require('../helpers/providers-stripe');
module.exports = class Charge {
constructor(opts = {}) {
this.amount = opts.amount;
this.currency = 'cad';
this.customer = opts.customer;
this.description = opts.description;
}
/*
Run a chain of promises
Catch pTwo because it's rejected
When handling the error, call a class instance method
*/
class CatchHandler {
constructor(){
this.value = 'visible'
}
// Why doesn't this return run p1, run p2, run p3
// currently returns run p1, run p3, run p2
const p1 = () => {
return new Promise((resolve, reject) => {
console.log('run p1');
setTimeout(resolve, 1000, 'p1');
})
};
self.signInSocial = function() {
return $q(function(resolve, reject) {
$cordovaOauth.facebook("208207529514102", [ "public_profile", "email"])
.then(function (result) {
var credentials = firebase.auth.FacebookAuthProvider.credential(result.access_token);
return firebase.auth().signInWithCredential(credentials);
})
.then(function (firebaseUser) {
resolve(firebaseUser);
})