Comments (6)
Oh, nice, I didn't know about that. We will add support for it.
from scala-commons.
Hi,
I'm not aware of any MongoDB projection operator that would do this (please let me know if you find one).
Assuming that there is no such operator in MongoDB API itself, you have two options:
- Map the projection itself in runtime, i.e.
RecordTestEntity.ref(_.innerList).map(_.map(_.int))
- the mapping will happen on the client side, MongoDB will not be aware of it and will be sending full objects on the wire. Note that this is largely equivalent to mapping theObservable
returned byTypedMongoCollection.find()
. - Use the Aggregation Framework - you will need to use the native API of the ReactiveStreams driver as it is not covered by AVSystem's Typed Mongo API
from scala-commons.
Just specifying the path to the field inside array (innerList.int
) works for me using Compass/MongoDB shell. https://www.mongodb.com/docs/manual/tutorial/project-fields-from-query-results/#projection-on-embedded-documents-in-an-array - the syntax is described here.
from scala-commons.
@AvaPL FYI: I hoped to do this quickly but it turned out to be somewhat annoying, mostly because of binary compatibility issues. We're still planning to do this one way or another.
from scala-commons.
No pressure, thank you for the information.
from scala-commons.
There's another use-case for innerList.int
path, i.e. it can be used to filter documents by inner field value as described here: https://www.mongodb.com/docs/manual/tutorial/query-array-of-documents/#specify-a-query-condition-on-a-field-in-an-array-of-documents. It would be nice if it was somehow supported by the driver.
Currently we do this kind of workaround, which works for queries and indexes, but it probably fails for updates.
final val InnerIntRef: Ref[Int] = FieldRef(ref(_.innerList), "int", implicitly, Opt.Empty)
from scala-commons.
Related Issues (20)
- GenCodec regression in 1.34.15 HOT 1
- Mapping scala BigDecimal to BSON NumberDecimal instead of binary HOT 3
- [TypedMongo] Allowing the discriminator field at any position HOT 7
- Accepting Ints as Doubles in BSON HOT 3
- Cannot pull single element by value in Mongo update HOT 2
- Scala 3? HOT 2
- Conditional beans include support in commons-spring
- Invalid condition generation in filtered positional operator
- Handle thrown exception outside the monadic context of Task
- Emptiness and Definition of Opt HOT 1
- quasi-Opaque types in Scala 2
- Investigation of failing Redis tests
- GenCodec for Seq creates a Vector instead of List when reading HOT 3
- Release for Scala 2.13.x HOT 3
- Possible DoS when parsing a JSON number to BigInt or BigDecimal HOT 5
- More user-friendly support of value classes HOT 2
- Compilation error in `materializeRecursively` call when upgrading to 1.34.3 version HOT 1
- Allow metadata annotations to accept arbitrary metadata parameters
- Require explicit @encoded annotation on @multi params/methods
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 scala-commons.