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

should dup behavior be reverted? #354

Open
cyjake opened this issue Sep 28, 2022 · 1 comment
Open

should dup behavior be reverted? #354

cyjake opened this issue Sep 28, 2022 · 1 comment

Comments

@cyjake
Copy link
Owner

cyjake commented Sep 28, 2022

The design of dup is mostly to solve confusing usages like below:

const query = Post.where({ published: true });
// SELECT * FROM posts WHERE published = 1 LIMIT 0,20;
const posts = await query.limit(pageSize).offset((page - 1) * pageSize);
// SELECT COUNT(*) FROM posts WHERE published = 1;
const count = await query.count();
@cyjake
Copy link
Owner Author

cyjake commented Sep 28, 2022

the bad part of this design is if user wants to construct query conditionally, they'd have to define the query as mutable, such as:

let query = Post.where({ published: true });
query = query.where('commentCount > ?', commentCount);

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

1 participant