I'm new to JS. I have the below snippet in some code I copied:
let pool;
const createPool = async () => {
pool = await mysql.createPool({
user: 'me',
password: 'guess',
});
};
createPool();
I'm trying to add a property to "pool", like this, right after the createPool() invocation,
pool.db = 'stuff';
but I get "pool undefined". I cannot (or maybe I can?) add that property in the {} definition because it's conditional on some other logic (which I can execute either before or after the declaration).
Can someone kindly educate --
- What is "pool"?
- What is this strange looking function (?) createPool?
- Why is pool undefined after the createPool() call? (Even the "let" should instantiate it, no?)
- How do I add the db property?
Thank you very much. -lostInJS