JavaScript How to properly implement mongodb async/await inside a promise?

I've read that having an async inside a Promise is anti-pattern for async/await. The code below works, but I am curious how else to achieve the same result without having async in Promise.

If I remove it, the linter would tell how I can't use await in my mongodb query. If I remove the await in the mongodb query, then it wouldn't wait for the result.

export const getEmployees = (companyId) => {
  return new Promise(async (resolve, reject) => {
    const employees = await Employees.find(
      { companyId },
    );

    // other logic here...

    resolve({
      employees,
    });
  });

Thanks.

Answer:1

I have a m("p.help") element which is removed with a click event. I also want the element to be removed automatically after a few seconds if not clicked. I need to set a time out on it. Setting time ...

I have a m("p.help") element which is removed with a click event. I also want the element to be removed automatically after a few seconds if not clicked. I need to set a time out on it. Setting time ...

This is the result: This is what the page shows when the JSON sets childnode.state.selected For example: {"children":[],"id":37,"text":"应用显 示","orderid":1,"parent":36,"state":{"disabled":false,"...

This is the result: This is what the page shows when the JSON sets childnode.state.selected For example: {"children":[],"id":37,"text":"应用显 示","orderid":1,"parent":36,"state":{"disabled":false,"...

I have a container that is a certain width. I have two select elements rendering on the same line in this main div container. The first one is absolute positioned 40px left from the main div ...

I have a container that is a certain width. I have two select elements rendering on the same line in this main div container. The first one is absolute positioned 40px left from the main div ...

Is there any way in which I can spy on the bunyan log to ensure I print out what I expect? MyFile.js const bunyan = require('bunyan'); const log = bunyan.createLogger({name: 'FailureAuditService'}); ...

Is there any way in which I can spy on the bunyan log to ensure I print out what I expect? MyFile.js const bunyan = require('bunyan'); const log = bunyan.createLogger({name: 'FailureAuditService'}); ...