Last active
August 20, 2020 16:58
-
-
Save jgdev/c01cb8a56aa3fd2ffc099acf9f685e6f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Example data in the collection: | |
* | |
* [ | |
* { _id: ObjectId(), key: "foo", value: "bar" }, | |
* { _id: ObjectId(), key: "fbKey", value: "123" }, | |
* { _id: ObjectId(), key: "logoUrl", value: "https://my-site.s3.aws.us-east-1/logo.png" }, | |
* ] | |
*/ | |
async getPortfolioSettings = () => { | |
const portfolioSettings = await db.getCollection("portfolio_settings").find({}); | |
return portfolioSettings.reduce((result, { key, value }) => ({ | |
...result, [key]: value, | |
}), {}); | |
} | |
getPortfolioSettings().then(console.log) | |
/** | |
* Expected output: | |
* | |
* { | |
* foo: "bar", | |
* fbKey: "123", | |
* logoUrl: "https://my-site.s3.aws.us-east-1/logo.png" | |
* } | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment