No field type for native Mongo ObjectId's?
See original GitHub issueAs far as I can tell, there’s no nice way to store Mongo’s native ObjectId type… https://docs.mongodb.org/manual/reference/object-id/
If the object exists in the same DB the Relationship type is appropriate:
someRelatedId: { type: keystone.Field.Types.Relationship, ref: 'SomeModelName', ... }
But if the object you’re referring to exists in a different DB you’re forced to use a string field:
someRelatedId: { type: String, ... }
… which works but, of course, stores the value as an arbitrary string and fails to leverage the underlying validation of the ObjectId type.
I half expected this would work:
someRelatedId: { type: keystone.mongoose.Types.ObjectId, ref: 'SomeModelName', ... }
… but apparently types must extend the Keystone Type class.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
types/mongodb _id is not necessarily typeof ObjectId #37439
I propose to add an union type for the ObjectID, and use that type for all _id or id references. That is; also...
Read more >ObjectId — MongoDB Manual
Generate a New ObjectId. To generate a new ObjectId, use ObjectId() with no argument: x = ObjectId() ; Specify a Hexadecimal String. To...
Read more >How to not use ObjectId() in node mongo native - Stack Overflow
The _id field of MongoDB can have any value you want as long as you can guarantee that it is unique for the...
Read more >[SPARK-132] org.bson.types.ObjectId is not a valid external ...
The core issue here is there is no native support in Spark for custom types. So the error is Spark is seeing an...
Read more >Spring Data MongoDB - Reference Documentation
The Spring Data MongoDB project applies core Spring concepts to the development of solutions that use the MongoDB document style data store.
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 FreeTop 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
Top GitHub Comments
It’s a lot of work to maintain a large open source project, and being focussed is one of the most important aspects of managing one. We had 600 open issues, of which we closed ~400 by simply moving all feature requests to Product Pains and another ~100 were duplicates or fixed.
This means two very beneficial things:
Which combined mean that in the long run, KeystoneJS will be a lot better off than if we didn’t do this. 👍
@mxstbr makes no sense to close issues just clear the tracker. Should only close when resolved or decided not be fixed/changed