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

ActiveRecord model is returning empty results everytime #2578

Closed
rangelfinal opened this issue Jul 24, 2018 · 4 comments
Closed

ActiveRecord model is returning empty results everytime #2578

rangelfinal opened this issue Jul 24, 2018 · 4 comments

Comments

@rangelfinal
Copy link

Issue type:
[X] bug report

Database system/driver:
[X] postgres

TypeORM version:
[X] latest (0.2.7)

Problem
ActiveRecord model is returning empty update results even when it's updating stuff in the database.

Steps to reproduce or a small repository showing the problem:

export default class OAuthAccessToken extends BaseEntity {
@Column() id: string;

@Column({ nullable: false })
  expires: Date;

public static async revoke(conditions: Partial<OAuthAccessToken>) {
    const now = new Date();
    return this.update({ ...conditions, expires: MoreThan(now) as DeepPartial<Date> }, { expires: now });
  }
}
const updateResult = await token.revoke({id: 'abc'}); // Token with id abc was updated in the database
console.log(updateResult); // UpdateResult { generatedMaps: [], raw: [] }
@pleerock
Copy link
Member

UpdateResult is somewhat system. What exactly do you expect update method to return?

@rangelfinal
Copy link
Author

Any kind of indication that the update was successful.
The full entities, their IDs or just a integer with the number of rows affected.
Even a boolean would do, but a indication of the number of rows affected would be better.

@pleerock
Copy link
Member

update is successful, otherwise promise would be rejected. Adding number of rows affected is a feature request, and we already have a one for it.

@rangelfinal
Copy link
Author

I will close this issue and follow the feature request, then.
For future reference, the feature request is the issue #1308.

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

No branches or pull requests

2 participants