-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Hello again! I wanted to touch base regarding a feature idea I had for my similar project: natevw/putdoc#9
To summarize my notes there, I'm wondering if you would also like to support a feature that will merge fields from certain JSON file(s) into their parent object? So that way one can set multiple fields in a top-level document using one JSON file [or possibly multiple, see below].
How it might look:
merge_example/
_id ('example')
_data.json ('{"type":"container", "name": "My Container", "owner":"me"}')
_attachments
file1.jpg
file2.pdf
[etc…]
Creates a document:
`{
"_id":"example",
"type":"container",
"name": "My Container",
"owner":"me",
"_attachments": {/* … */}
}
It should be a relatively easy add into putdoc at least technically, but if you had interest too I wanted to collaborate on some of the design decisions:
How to trigger it? My basic idea so far is by a special file name (like we have withI implemented this via the_attachmentsand_docsfolders) in the example above it's_mergeor maybe e.g._fields/_data/…. The actual file 99% of the time would have a JSON extension but I suppose could theoretically be a nested document [not sure the use case but keep things consistent…] or possibly some other extension that is used for serializing an object (think YAML/XML but to be clear I have no plans to support those in putdoc)._dataoption, for better or worse.Is it simple and worthwhile enough to support multiple such files e.g.I also implemented this. I left the merge order unspecified; for now conflicting (i.e. duplicate) keys are discouraged and should not be expected to yield stable results._merge.one.json_merge.two.jsonand_merge.jsonwould all three have their fields merged into their context.- Any other feedback?
Thanks for your time!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels