-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Query] How would I flatten an array inside an object? #7
Comments
Hi, Currently array's are set as they are, meaning no flattening is applied inside array's documents. var $ = require('mongo-dot-notation')
var data = {
"ipv4": {
"enable": "yes",
"rule": $.$(0).$set({
"flow": {
"destinationAddress": "0.0.0.0"
}
})
}
}
var flat = $.flatten(data)
/* ouputs:
{
$set: {
'ipv4.enable': yes,
'ipv4.rule.0': { flow: { destinationAddress: '0.0.0.0' } }
}
}
*/ This will set the first embedded document in the I might consider adding your request as a feature to be added in the next releases. |
Thanks for the quick turnaround @dimadeveatii |
hi @bharathkeshav12, I'm interested in that package that you found, do you mind sharing it? |
Is this still on the radar to be completed eventually? Would be really helpful for a project I'm working on that has a lot of nested objects in arrays, where I need to update deeply nested values. |
Hi @lsaether, this feature was not added yet as there was no real demand. Could you please describe your exact usage and need? Is it the same as described in the initial post? |
Happy to announce array support has been added. mongo-dot-notation/tests/flatten.spec.ts Lines 307 to 327 in 0c983bf
|
Hi,
This is not an issue. I'd just like to know if this is possible:
I have an object:
I'm looking to produce an output like:
Is this possible?
The text was updated successfully, but these errors were encountered: