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

method: #has #18

Open
Saviio opened this issue Aug 4, 2017 · 3 comments
Open

method: #has #18

Saviio opened this issue Aug 4, 2017 · 3 comments

Comments

@Saviio
Copy link
Contributor

Saviio commented Aug 4, 2017

增加一个函数来同步判断某个 Id 数据是否存在于db中

const db = new Database()
db.has('tableName', primaryKey) // return boolean
@Brooooooklyn
Copy link
Member

为什么有这种需求

@Brooooooklyn
Copy link
Member

为什么不:

db.get('tableName', { where: { primaryKey: 'xxxx' } })
  .values()
  .do((r) => r.length)

@Saviio
Copy link
Contributor Author

Saviio commented Aug 4, 2017

原因比较naive,其实实现这个feature大概就3行代码....但后来我那个场景可能不需要这个了,我再评估一下。 至于为什么不 query 一下,因为异步-0-,而且我只是想判断一下在不在而已

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

No branches or pull requests

2 participants