Open ghost opened 4 years ago
Hey, thank you for filing the issue. Deleting a database makes sense, and we'll add this to the backlog.
There is no hard limit on the number of databases, and having a database per feed sounds like the right approach for what you're doing.
You can also have another database for feed metadata, in which you'd have one record per feed. Until we support deleting a database, you may simply flag it as deleted and not show it to the user. Then once the deleteDatabase function is available, you can simply walk over the list and delete all those that are flagged for deletion. We'll try to prioritize this asap, but this can help you get unblocked.
Makes sense, and thanks. That's what I'll do for now.
@j-berman I am currently considering trying to implement this feature. Since you assigned the issue to yourself a while back, I wanted to ask if you accept PRs and think it's doable for someone with not quite the overview of the code. I've had a rough look through the code and have a few ideas on how this might work.
I would try to build the feature so that only owner can delete databases. If the owner deletes the DB, then all "Share-DBs" of this DB, are also deleted.
@Fubinator I'm sorry for the mega delayed response. Would absolutely accept PR's :) I think it's doable but there's a bit more underneath the surface that makes it trickier to handle because of the web socket, here are some pointers:
userDb
should be marked for deletion via a new deleted
flag with the date (no need to mark all other "share-DBS" referred to as userDbs
in the server-side code for deletion). In purge.js
, there should be a new scanForDeletedDatabases
function that follows scanForDeletedUsers
, scanForDeletedApps
etc. Note there is a useful purgeTransactions
which will get rid of the needed data depending on whether or not the user deleting is an owner. The flow of user deletion, app deletion, and admin deletion can serve as a useful guide.userbase-server/ws.js
, iterate over Connections.sockets[databaseId]
and mark them closed such that isDatabaseOpen
will return false for users accessing the database (see closeUsersConnectedClients
as a guide).deleted
flag.Happy to accept a PR from anyone on this. I will get to it within the next 6-9 months if not. It's one of the more demanded features and I'm looking to get back into adding more features.
@j-berman Any update on this?
Unfortunately not :/ this likely won't get implemented in the foreseeable future unless we get a PR from someone. I have a few things I still want to implement for Userbase I put at a higher priority and don't have much bandwidth at the moment
It doesn't look like there's an SDK method for deleting a database—only one for deleting individual items in batches of ten.
I'm building an RSS reader and using Userbase to sync feed subscriptions and unread articles. I thought I'd create a
feeds
database and store each feed as an item in it. Like so:However, it's not uncommon for a user to let unread articles pile up, leading to tens or hundreds of unread. It makes sense to limit unread articles somewhat—perhaps to the most recent hundred. But the 10 KB limit on a databases items prevents me from storing even 50
unread
.So I'm instead creating a database per feed, while storing each
unread
as an individual item. I never run up against the 10 KB limit for items, of course. But it's cumbersome to clear out a feed database in batches of ten (rate-limited, of course) after a user has unsubscribed from a feed. I'd like to simply delete the database and be done.I also wonder. Is creating a database per feed even advisable? It's the only way I can see an RSS reader existing given the 10 KB item limit. But is there a hard limit on databases per user? Because I can easily imagine users who are subscribed to a couple hundred feeds. If there is a limit, some error messaging would be helpful.
Anywho, thanks for making Userbase.