Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@property.array does not convert string to MongoDB ObjectId #5848

Closed
haotangio opened this issue Jun 29, 2020 · 1 comment · Fixed by loopbackio/loopback-connector-mongodb#582
Assignees
Labels

Comments

@haotangio
Copy link
Contributor

haotangio commented Jun 29, 2020

Backgrounds

I'm building many-many relation on MongoDB but LB4 doesn't support ReferencesMany yet so in the meantime I have to work-around by configure entity like below:

// film.ts
...
@property.array(String, {mongodb: {dataType: 'ObjectID'}})
directorIds: Array<string>;
...

Steps to reproduce

When I save directorIds like below. The ID array is stored as string in MongoDB.

// film-controller.ts

...
film.directorIds = ['5eec55b897e7bf6b05210e48', '5eec55b897e7bf6b05210e49'];
await this.filmRepository.save(film);
...

Current Behavior

The ID array is stored as list of string in MongoDB.

Expected Behavior

The ID array is stored as list of ObjectId in MongoDB.

Additional information

The root cause of this problem is that ReferencesMany is not supported yet while it's the critical feature to develop any systems using MongoDB. There is no timeline for it and the GH ticket for it is staled for almost a year.

@haotangio haotangio added the bug label Jun 29, 2020
@haotangio haotangio changed the title @property.array does not work with MongoDB ObjectId array @property.array does not convert string to MongoDB ObjectId Jun 29, 2020
@jannyHou
Copy link
Contributor

Thank you @agnes512 for helping triage this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants