Find select field
See original GitHub issueI have nations with settlements with members, I’m trying to get all of the members of the nation through the settlements.
val members: List<SLPlayerId> = Settlement.COL
.find(Settlement::nation eq id).projection(Settlement::members)
.map { it.members }
.flatten()
This gives me this error:
[08:01:22 ERROR]: [SLCore] [ACF] Caused by: com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException: Instantiation of [simple type, class net.starlegacy.slcore.mongo.Settlement] value failed for JSON property territory due to missing (therefore NULL) value for creator parameter territory which is a non-nullable type
[08:01:22 ERROR]: [SLCore] [ACF] at [Source: de.undercouch.bson4jackson.io.LittleEndianInputStream@24d5132b; pos: 148] (through reference chain: net.starlegacy.slcore.mongo.Settlement["territory"])
Is there a way to get the value without attempting to construct the whole object?
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Mongoose, Select a specific field with find - Stack Overflow
The _id field is always present unless you explicitly exclude it. Do so using the - syntax: exports.someValue = function(req, res, ...
Read more >Project Fields to Return from Query — MongoDB Manual
Use the Select your language drop-down menu in the upper-right to set the ... the db.collection.find() method returns all fields in the matching...
Read more >How to select fields in a document in MongoDB
MongoDB is really easy to work with. Today, we will see how to select only few fields out of a large document using...
Read more >Select fields (Concepts) - Prisma
This page explains how to select only a subset of a model's fields and/or include relations ("eager loading") in a Prisma Client query....
Read more >Retrieve selected fields from a search | Elasticsearch Guide [8.5]
Use the docvalue_fields parameter to get values for selected fields. This can be a good choice when returning a fairly small number of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You have two options:
This will not work if
members
is a complex object.Also I’m going to add a projection extension method, in order to project “out of the box” one, two or three fields.
HTH
Okay, hopefully you’ll find what I came up with helpful 😃