File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change 22const { aql, query, db } = require ( "@arangodb" ) ;
33const users = require ( "@arangodb/users" ) ;
44
5- const expirationTime = ( 4 * 60 * 60 * 1000 ) // 4 hours
5+ const expirationTime = ( 4 * 60 * 60 * 1000 ) // 4 hours or use (30 * 1000) for 30 seconds
66const expired = [ ] ;
77
88let dbs = query `
@@ -16,12 +16,18 @@ dbs.toArray().map((d) => {
1616let cleanupCollection = query `
1717FOR key IN ${ expired }
1818FOR i IN tutorialInstances
19- FILTER i._key
19+ FILTER i._key == key
2020INSERT {email: i.email, username: i.username, dbName: i.dbName} INTO expiredtutorialInstances
21- REMOVE { _key: i._key } IN tutorialInstances` ;
21+ REMOVE { _key: key } IN tutorialInstances` ;
2222
2323function removeDatabase ( dbName , key , username ) {
24- users . remove ( username ) ;
25- db . _dropDatabase ( dbName ) ;
26- expired . push ( key ) ;
24+ if ( users . exists ( username ) ) {
25+ users . remove ( username ) ;
26+ }
27+ try {
28+ db . _dropDatabase ( dbName ) ;
29+ expired . push ( key ) ;
30+ } catch ( err ) {
31+
32+ }
2733}
You can’t perform that action at this time.
0 commit comments