'Cannot display Playground Result.json using MongoDB for vscode
When i launch queries from a playground(.mongodb) file using the mongodb extension for vscode the result is correctly printed in the console of vscode but it doesn’t appear the json tab(Playground result.json) showing the same result but in json format…(as it should happen according to the documentation) I’m using vscode for macbook
Solution 1:[1]
Was your query without print command? (e.g. db.tests instead of print(db.tests))
If so
Note that print and console.log will print in the VS Code Output panel, while the result of the playground is displayed in an editor.
See https://www.mongodb.com/community/forums/t/print-function-in-vscode-extension-is-missing/103118/2
Solution 2:[2]
You could take a looking ahead and replace the comma, followed by dollar sign.
const
replace = string => string.replace(/,(?=\$)/g, '|'),
string = '$2,500,$3,500';
console.log(replace(string));
Solution 3:[3]
A solution without regex:
x = '$2,500,$3,500'
let res = x.replace(",$", "|$");
console.log(res)
And if you have multiple values:
x = '$2,500,$3,500,$123,456'
let res = x.replaceAll(",$", "|$");
console.log(res)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | SaharatT |
| Solution 2 | |
| Solution 3 |
