How to delete documents

How we can delete a document form the database ? Is there any way to do this when we don’t want to use this one any more or delete cause was created by accident ?

:pray::pray: no one know how to do that ?

I have the same problem
I want to destroy the doc because the doc.store.pendingStucts is too big ,which i think slow down everything , I am plagued by this (>c<!!!)

Providers typically have a clearData or clearDocument function for this purpose.

hi, thanks for replying , but i can only find limited functions in

missing clearData or clearDocument ,is there some document that i miss out ?

y-websocket does not have a clearDocument function because it doesn’t persist data itself. It is only a network provider.

However it does have a LeveldbPersistence instance built-in if you specify a YPERSISTENCE environment variable. If you’re using YPERSISTENCE, you can use import getPersistence from the server to get the LeveldbPersistence instance and then call clearDocument from there. That path is not very well documented.

However, even without persistence (to disk), if there is any Doc living in memory then the Doc will persist in memory. That means you need to shut down the server and close all browser windows that are using the Doc. Otherwise, the websocket provider will re-sync your client-side Doc as soon as you refresh, or inversely your client-side Doc will re-sync your websocket provider as soon as the server restarts. You have to kill both at the same time to keep the Doc from coming back to life :man_zombie:

1 Like

Your description matches my practice result , I kept killing y-websocket pid , it seemed can’t be killed ultimately at first, the situation was just as you said, and after I finally restarted the server, the doc size decreased sharply, and I think I shoud do some reconstruction things next to prevent the doc being big large again. Thank you very much !!!

1 Like