Skip to content

Stop auto-casting string to & from ObjectId #1761

Open
@halaei

Description

@halaei

I need to know if there is any chance of having a branch that doesn't automatically cast string to and from ObjectId. Also a branch in which all the relations and eager loading work when foreign keys are ObjectId.

What is wrong about current behavior:

  1. Having a foreign key of type string referencing an ObjectId field is the a terrible idea, because some possible join queries in MongoDB turn impossible by this type of referencing.

  2. You may sometimes want to have a key that is actually a string. But if the input value looks like an ObjectId, this package convert it into ObjectId, which is again terrible in both querying and saving documents in MongoDB.

  3. I am not sure, but maybe these magical conversion was around because of some limitations in legacy MongoDB drivers. The limitations are no more.

If this change breaks conventions like route bindings and toArray(), I am sure we can easily find better solutions for them as well.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions