Feat: AsyncLocalStorage for schema changing

This commit is contained in:
csrapr 2021-03-02 16:22:35 +00:00 committed by Josh Harvey
parent e6059be8d2
commit 351d170c31
5 changed files with 55 additions and 27 deletions

12
lib/async-storage.js Normal file
View file

@ -0,0 +1,12 @@
const { AsyncLocalStorage } = require('async_hooks')
const asyncLocalStorage = new AsyncLocalStorage()
const defaultStore = (a = null) => {
const store = new Map()
store.set('schema', 'public')
store.set('defaultSchema', 'ERROR_SCHEMA')
if (a) store.set('a', 'a')
return store
}
module.exports = { asyncLocalStorage, defaultStore }