Skip to content
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

Dynamic / high order attribute values (e.g. an attribute being a sum of two other attributes) #3815

Open
fgalan opened this issue Mar 18, 2021 · 1 comment

Comments

@fgalan
Copy link
Member

fgalan commented Mar 18, 2021

The idea is to define somehow (an special operation on the entity?) virtual attributes that are the result of doing an operation over other attributes in the same entity.

Some examples:

  • A and B being numeric attributes, we define S as the sum of A and B. If we do a GET on the entity we will get:
GET /v2/entities/E/attrs

{
  "A": { "value": 10, "type": "Number" },
  "B": { "value": 20, "type": "Number" },
  "S": { "value": 30, "type": "Aggregated" },
}
  • A and B being arrays, we define S as the intersection of A and B. If we do a GET on the entity we will get:
GET /v2/entities/E/attrs

{
  "A": { "value": [ 1, 2, 3, 4], "type": "StructuredValue" },
  "B": { "value": [3, 4, 5, 6], "type": "StructuredValue" },
  "S": { "value": [3, 4], "type": "Aggregated" },
}

The key point is that, from the point of view of the client doing the GET requests, this is completely transparent. I mean, S should behave as "regular" attributes A and B (e.g. from the point of view of q filtering, etc.).

Of course, not only for synchronous GETs. Notifications should work the same way.

From an implementation point of view, two basic alternatives should be explored:

  • Take advantage of the MongoDB aggregation framework
  • Implement the operation at CB code space
@fgalan
Copy link
Member Author

fgalan commented Feb 12, 2024

Probably this issue could be achieved leveraging issue #4513

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant