dce-mango
Version:
Harvard DCE's Non-relational DB Wrapper.
25 lines (21 loc) • 598 B
text/typescript
// Import state
import dbState from './dbState';
/**
* Close the current Mango session - mainly for testing or short script purposes.
* @author Benedikt Arnarsson
*/
const closeMango = async () => {
if (!dbState.isInitialized) {
// TODO: better error message
throw new Error('Cannot close a connection that hasn\'t been initialized.');
}
// Close connection:
await dbState.client.close();
// Reset dbState:
dbState.isInitialized = false;
dbState.schemaVersionTag = '';
dbState.initDB = null;
dbState.db = null;
dbState.client = null;
};
export default closeMango;