Skip to content

update multiple records via ResultReference #315

Description

@dcwatson

Apologies if I missed it, but there doesn't seem to be a way to use a ResultReference to do a /set completely server-side. I think there are a number of good use-cases for being able to do this efficiently (mostly around updating based on a query), and I think it could be done with fairly minimal modifications to the spec. I'm imagining the ResultReference type gaining a new (optional) property -- call it properties or setProps or something -- that would cause the reference to resolve to a JSON object with the keys being taken from the pointer resolution, and values being whatever you pass. For example:

[["Email/query", {
    "accountId": "a1",
    "filter": {"from": "nobody"}
}, "eq"],
["Email/set", {
    "accountId": "a1",
    "#update": {
        "resultOf": "eq",
        "name": "Email/query",
        "path": "/ids",
        "properties": {
            "keywords/from-nobody": true
        }
    }
}, "es"]]

If the Email/query call returned {"ids": ["e1", "e2"]}, the Email/set call would resolve to:

["Email/set", {
    "accountId": "a1",
    "update": {
        "e1": {
            "keywords/from-nobody": true
        },
        "e2": {
            "keywords/from-nobody": true
        }
    }
}]

What do you think? Does this sound like something worth considering? My hunch is that it will require some discussion before it's worthwhile to create a PR, but I can take a stab at it if it would be helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions