简体   繁体   中英

How can i clean pouchdb when electron app is closing

I have some PouchDBs in my electron app, and i need to clear some of these dbs when the app is closing or make these dbs only for that session!

I have currently 3 dbs: auth (i dont want to clear this one), home and page. I want to keep the db while the app is running because it improves loading time, but when a new instance of the app is open i want these last 2 to be with no data.

Any ideas?

In-Memory adapter for PouchDB maybe?

Or another idea: Create a random string when the app starts, create the PouchDB database with the string as suffix, for example home-MjlhOGFlYmEy , dump the data in there. A new instance of the app will use a different suffix and has a separate database. This, of course, doesn't clean old data. You could then think of strategies how to clean the old data, for example by keeping a list of all suffixes and have some garbage collector running that cleans old databases that are not in use anymore.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM