本文整理汇总了TypeScript中firebase/app.database函数的典型用法代码示例。如果您正苦于以下问题:TypeScript database函数的具体用法?TypeScript database怎么用?TypeScript database使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了database函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: Promise
return new Promise((resolve) => {
firebase.database()
.ref(`/${query.db}`)
.orderByChild("inhdd")
.equalTo(1)
.on("value", (data) => resolve(this.objectToArray(data.val())));
});
示例2: constructor
constructor(model: BagitModelService)
{
this._curFirebaseUser = undefined;
this._currentUser$ = new BehaviorSubject<User | null>(null);
this._model = model;
//
// Setup to handle authentication state changes.
//
this._authInitializedPromise = new Promise((resolve) => {
// Hang on to the resolve function so that we can call it once the
// initial auth state change happens.
this._resolveAuthInitializedPromise = resolve;
});
this._firebaseAuth = auth();
this._firebaseAuth.onAuthStateChanged(this.onAuthStateChanged.bind(this));
this._isConnected$ = new BehaviorSubject<boolean>(false);
const connectedRef = database().ref(".info/connected");
connectedRef.on("value", (snap: database.DataSnapshot | null) => {
if (snap) {
this._isConnected$.next(snap.val());
}
});
}
示例3: inject
inject([FirebaseApp, AngularFireDatabase], (_app: firebase.app.App, _db: AngularFireDatabase) => {
app = _app;
db = _db;
ref = firebase.database().ref();
O = new FirebaseObjectObservable((observer: Observer<any>) => {
}, ref);
})();
示例4: update
update(params: FirebaseQuery) {
const { db, id, data } = params;
if (db && id && data) {
return Promise.resolve(firebase.database()
.ref(`/${db}/${id}`)
.update(data));
}
return Promise.reject();
}
示例5: hardDelete
hardDelete(params: FirebaseQuery) {
const { db, id } = params;
if (db && id) {
return Promise.resolve(firebase.database()
.ref(`/${db}/${id}`)
.remove());
}
return Promise.reject();
}
示例6: it
it('should call off on all events when disposed', (done: any) => {
const questionRef = firebase.database().ref().child('questions');
var firebaseSpy = spyOn(questionRef, 'off').and.callThrough();
subscription = FirebaseListFactory(questionRef).subscribe(_ => {
expect(firebaseSpy).not.toHaveBeenCalled();
subscription.unsubscribe();
expect(firebaseSpy).toHaveBeenCalled();
done();
});
});
示例7: addUnreadMessage
addUnreadMessage(workerId: any) {
let databaseRef = firebase.database().ref(`/workerList/${workerId}`).child('unreadMessages');
databaseRef.transaction(function (searches) {
if (searches || searches == 0) {
searches = searches + 1;
}
return searches;
});
}
示例8: beforeEach
beforeEach((done: any) => {
toKey = (val) => val.key;
val1 = { key: 'key1' };
val2 = { key: 'key2' };
val3 = { key: 'key3' };
firebase.database().ref().remove(done);
questions = FirebaseListFactory(`questions`);
questionsSnapshotted = FirebaseListFactory(`questionssnapshot`, { preserveSnapshot: true });
ref = questions.$ref;
refSnapshotted = questionsSnapshotted.$ref;
});
示例9: LoginDialog
$(async () => {
if (user === null) {
this.budget = null
Spinner.hide();
if (this.transactionList) { this.transactionList.clear(); }
// show the login dialog
this.pnlMenu.close();
let loginDialog = new LoginDialog(this.login.bind(this), this.resetPassword.bind(this), this.signup.bind(this));
loginDialog.open();
} else {
ModalSpinner.show();
let config = (await firebase.database().ref(user.uid).child('config').once('value')).val() as ConfigurationData;
if (config === null || config.showWizard == true) {
// not yet initilized or need to see the wizard
ModalSpinner.hide();
await ShowIntroWizard(firebase.database().ref(user.uid).child('config'));
ModalSpinner.show();
}
this.budget = new Budget(firebase.database().ref(user.uid));
this.budget.on('config_read', this.config_onRead.bind(this));
this.budget.on('history_change', () => {
this.btnUndo.disabled = !this.budget.CanUndo;
this.btnRedo.disabled = !this.budget.CanRedo;
});
this.budget.ready().then(() => {
this.previewer.listenToTransactions(this.budget.Transactions);
this.transactionList.listenToTransactions(this.budget.Transactions);
this.chart.listenToTransactions(this.budget.Transactions);
this.budget.on('loadperiod', this.periodLoaded.bind(this));
// this.gotoDate(Date.today());
this.budget.gotoDate(Date.today());
});
}
});
示例10: supplyRequested
export const requestSupply = (room: Room, supply: Supply) => {
firebase
.database()
.ref(`roomSupplies/${room.id}_${supply.id}`)
.update({
room: room.id,
supply: supply.id,
requested: firebase.database.ServerValue.TIMESTAMP,
});
supplyRequested(supply, Date.now());
setRequestedSupply(supply);
};
示例11:
export const unsubscribeFromSupplies = (room: Room, supplies: Supply[]) => {
if (room) {
firebase
.database()
.ref(`rooms/${room.id}/supplies`)
.off('child_added');
supplies.forEach((supply) => {
firebase
.database()
.ref(`roomSupplies/${room.id}_${supply.id}/requested`)
.off('value');
});
}
};
示例12: Supply
.once('value', (supplySnapshot: DataSnapshot<Supply>) => {
const supply = new Supply({ id: supplySnapshot.key }, supplySnapshot.val());
addSupply(supply);
firebase
.database()
.ref(`roomSupplies/${room.id}_${supply.id}/requested`)
.on('value', (requestedSnapshot: DataSnapshot<number>) => {
const requested = requestedSnapshot.val();
if (requested) {
supplyRequested(supply, Math.min(requested, Date.now()));
}
});
});
示例13: removeOrderFromDayPlan
removeOrderFromDayPlan(dayPlanId: any, orderId: any) {
return firebase.database().ref(`/dayPlanList/${dayPlanId}/ordersObj/`).child(orderId).remove();
}
示例14: updateOrder
updateOrder(dayPlanId: any, orderId: any, order: any) {
return firebase.database().ref(`/dayPlanList/${dayPlanId}/ordersObj`).child(orderId).set(order);
}
示例15: updateDayPlan
updateDayPlan(dayPlanId: any, dayPlan: any) {
return firebase.database().ref(`/dayPlanList/`).child(dayPlanId).set(dayPlan);
}