Create a whole path in Objects/Maps in one line #960
Unanswered
Kerollmops
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Such a feature is probably easy to add but figuring out a nice simple syntax for it is less straightforward... You may, however, use a function to do this very easily. Just write a function that takes a map as object, and use the passed in map to merge into it, creating intermediate objects as needed. Then overload that on Then you can do:
Pitfall is that you'd need all properties defined in the map, with |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello 👋
We use Rhai in Meilisearch to programmatically modify JSON documents. It's very useful. But sometimes, we need to modify deep fields enclosed in multiple layers of objects, like the following.
I would like to know if there is any better way to create intermediate objects when modifying the
myEmbedding
field than using the following program. Something likemkdir -p
would be great to create the intermediate folders if necessary and fail if something exists in the path that is not already an object. Using the Elvis operator obviously doesn't work, and stops at the first nil.Beta Was this translation helpful? Give feedback.
All reactions