-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Possible bug inside findOne with MongoDB #2674
Comments
You need to use 2 different repository for this case. See here atest model doesn't have an id column as you shared earlier. So it cannot search by id on that. Even if it had, that should correspond to id field in atest model. It can never be test model id. I think what you intend to do is
Note I am using testRepository here. That should work. BTW, I think stack overflow is a better place for raising such queries. |
yes I noted that you used @dhmlau @bajtos , can you please check this issue because it does not make our project workable? |
@b-admike , could you please take a look? thanks. |
I think this is related to the pull requests that @hacksparrow is working on now, see loopbackio/loopback-connector-mongodb#517 and loopbackio/loopback-connector-mongodb#525 |
@hacksparrow, is this issue resolved since the two above PRs had landed? |
ObjectID strings behave in a predictable manner now, in There is a crucial missing piece in the example app provided by @frodoe7 - the creation aspect of the models. We don't know how the models are populated in the databases. |
@frodoe7 also, the property name should be |
FWIW, while playing with relations, I discovered an important limitation of the current solution based on juggler v4 and mongodb connector: when the primary key (id property) is configured as An example model definition that's affected: @model()
class MyModel extends Entity {
@property({
type: 'string',
id: true,
generated: true,
})
id: string;
} I am not sure yet whether this is a problem and how to address it if it is a problem. |
Hello, As an example, the following works: The following not work: Is there a possible workaround? Thank you. |
@UnclePetros what is the property |
@hacksparrow
I use a mongodb datasource. Unfortunately I've tried to reproduce it in the todo-list example, but without success. |
@UnclePetros that's correct |
@hacksparrow ok, very interesting this new feature. |
@hacksparrow @UnclePetros, is this ticket good to close then? Thanks. |
Hello, yes of course. |
Closing as done. |
Description / Steps to reproduce / Feature proposal
I have only 2 models test and atest
test has (id,name,age)
atest has (testId) which refers to the id from test model
I have only 1 controller for (atest) with 2 ENDPOINTS
get '/eltest' > which findOne by the testId
get '/anothertest' > which findOne by the id
Current Behavior
the first one works well - but the second one not find the exist record
Expected Behavior
both should work and find the exist record inside the database
Searches and solutions I tried with
changing @model() to @model({ settings: { strictObjectIDCoercion: true, }, }) inside atest model ;
works like a switch - it damage the working ENDPOINT and fix the damaged ENDPOINT
please use this repo to reproduce the issue
The text was updated successfully, but these errors were encountered: