Search code examples
node.jsfirebasefirebase-realtime-databasevitesveltekit

Firebase db._checkNotDeleted is not a function when updating realtime database


I'm using @firebase/database's set function to update the tree but I recieve the following error:

Reference_impl.ts:482 Uncaught (in promise) TypeError: db._checkNotDeleted is not a function
    at ref (Reference_impl.ts:482:6)
    at HTMLInputElement.keypress_handler (__layout.svelte:85:25)
ref @   Reference_impl.ts:482
keypress_handler    @   __layout.svelte:85

My code is the following:

let updates = {};

let chatID = [fb.auth.currentUser.uid, userID].sort().join('-');

let users = {};

users[fb.auth.currentUser.uid] = true;
users[userID] = true;

let chat = {
    type: 'direct',
    users: users,
    id: chatID,
    timestamp: Date.now()
};

updates['/chats/' + chatID] = chat;

updates['/users/' + fb.auth.currentUser.uid + '/chats/' + chatID] = true;
updates['/users/' + userID + '/chats/' + chatID] = true;

return await set(ref(fb.db), updates);

Edit: imports:

import { get, ref, set } from '@firebase/database';

fb is a Firebase initialization script I've made


Solution

  • fb.db was Firestore, fb.database was realtime. Thanks Phil.