question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No field type for native Mongo ObjectId's?

See original GitHub issue

As 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:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
mxstbrcommented, Jun 4, 2016

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:

  1. We’re hyper aware of which bugs exist in KeystoneJS and need to be fixed (not possible with 600 open issues, very possible with 100 open ones)
  2. We know which features the community wants most since we you can upvote them (not possible with Github issues)

Which combined mean that in the long run, KeystoneJS will be a lot better off than if we didn’t do this. 👍

0reactions
rturkcommented, Jun 4, 2016

@mxstbr makes no sense to close issues just clear the tracker. Should only close when resolved or decided not be fixed/changed

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found