File tree 1 file changed +12
-6
lines changed
1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change 2
2
const { aql, query, db } = require ( "@arangodb" ) ;
3
3
const users = require ( "@arangodb/users" ) ;
4
4
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
6
6
const expired = [ ] ;
7
7
8
8
let dbs = query `
@@ -16,12 +16,18 @@ dbs.toArray().map((d) => {
16
16
let cleanupCollection = query `
17
17
FOR key IN ${ expired }
18
18
FOR i IN tutorialInstances
19
- FILTER i._key
19
+ FILTER i._key == key
20
20
INSERT {email: i.email, username: i.username, dbName: i.dbName} INTO expiredtutorialInstances
21
- REMOVE { _key: i._key } IN tutorialInstances` ;
21
+ REMOVE { _key: key } IN tutorialInstances` ;
22
22
23
23
function 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
+ }
27
33
}
You can’t perform that action at this time.
0 commit comments