Comments (7)
Hi everyone!
We have now launched this functionality as math::sum()
, along with a bunch more stuff.
We have also launched a new GROQ spec, which you can read about in our blog: Content is Queryable: (Re)Introducing GROQ.
from groq.
any alternatives for the mean time? or do I really need to handle this JS side for now?
We definitely want to add this in the future, but at the moment we don't have a timeline for when it will be available. For now you need to handle this in JS.
from groq.
Any word on this? Would be super useful for something I'm working on.
from groq.
I don't think it should be too hard to do, but I'll leave it to @judofyr to triage it.
from groq.
I would also love to see this. Here is an example usecase
Example dataset
{
"_type":"invoice",
"request":{
"_ref":"...",
"_type:":"reference"
},
"items":[
{
"itemId":1,
"price":1000
},
{
"itemId":2,
"price":2000
},
{
"itemId":3,
"price":3000
}
]
}
An example query where this would be super usefull
*[_type=="request" && _id == $id]{
invoices: *[_type=="invoice" && reference(^._id)]{
"totalPrice": sum(items[].price), // shows the total price of all the items eg; 6000
items
}
}[0]
from groq.
Echoing this, it would be nice to be able to add the up the size fields from the media in order to determine the size of a given group of media:
*[ _type in ["sanity.imageAsset", "sanity.fileAsset"] ]{"totalSize": sum(items[].size)}
from groq.
any alternatives for the mean time? or do I really need to handle this JS side for now?
from groq.
Related Issues (20)
- Feature request: Don't return null values from groq query HOT 2
- GROQ query order(_createdAt desc) doesn't work for multiple document types at once HOT 1
- GROQ Text matching with _id
- Using params in functions (E.g. `*[] | order($orderBy)`)
- Dot character in document identifier leads to null value in dereferenced array HOT 1
- GROQ MarkDefs queries do not apply for MarkDefs which are inside list items HOT 1
- Difference when comparing array with array in current object or in parent object HOT 1
- Extra function suggestions. HOT 1
- global::operation() or delta::operation() HOT 2
- `-2**-2` Can be parsed two different ways HOT 3
- [GROQ] Why can't I project a primitive to an object?
- Range in `in`
- Feature Request: Random Document Retrieval in GROQ
- Feature Request: Typecasting in GROQ for String Comparison
- The readme copyright line is potentially invalid
- documentation
- score/boost with nested items/portable text
- `score()` returns `null` when used in a joined query HOT 5
- Spread operators breaks sibling reference field projections, or reference field projections in conditionals HOT 2
- GROQ v1 not dereferencing asset in one situation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from groq.