We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
@kintone/rest-api-client
アプリの一覧画面にボタンを設置して、 クリックすると、ビューの絞り込み条件・ソート条件をそのまま使ってデータ取得する というケースがよくあります。
その際に、こんな風に書くわけですが、
const records = await client.record.getAllRecords<MyRecordType>({ app: kintone.app.getId(), fields: ['foo', 'bar', 'baz'], condition: kintone.app.getQueryCondition(), orderBy: kintone.app .getQuery() .replace(/.*order by /i, '') .replace(/limit.*/i, ''), })
fieldsとorderByがなかなか冗長になってしまうので、 「画面の条件を自動反映する」というオプションがあると、とても開発が楽になりそうです。
たとえば、それぞれのプロパティにオブジェクト型も入れられるようにして、 こんな風にすると、アプリの設定を全自動で反映してくれるイメージです。
const records = await client.record.getAllRecords<MyRecordType>({ app: { type: 'asIs' }, fields: { type: 'asIs' }, condition: { type: 'asIs' }, orderBy: { type: 'asIs' }, })
従来の型と混在も可能
const records = await client.record.getAllRecords<MyRecordType>({ app: { type: 'asIs' }, fields: ['foo', 'bar', 'baz'], })
従来の使いかたをオブジェクトで書くことも可能
const records = await client.record.getAllRecords<MyRecordType>({ app: { type: 'toBe', value: kintone.app.getId() }, fields: { type: 'toBe', value: ['foo', 'bar', 'baz'] }, condition: { type: 'toBe', value: `foo != ""` }, orderBy: { type: 'toBe', value: 'foo asc, bar desc' }, })
もちろん、この通りの仕様で実装してくれなくても良いですが、 何かしらヒントになればと思います!
あるいは、kintone JavaScript API自体にこんな関数が追加されると これだけでよくなるんですけどね。
const records = await client.record.getAllRecords<MyRecordType>({ app: kintone.app.getId(), fields: kintone.app.getViewFields(), // new! condition: kintone.app.getQueryCondition(), orderBy: kintone.app.getQueryOrder(), // new! })
ご検討、よろしくお願いします!
The text was updated successfully, but these errors were encountered:
こちら、どなたか確認して頂けたでしょうか・・・? 何かしらリアクションもらえると有り難いです 😢
Sorry, something went wrong.
@the-red
Sorry, we missed this issue. We will check and respond to you soon. Thank you for your patience.
@the-red フィードバックありがとうございます!
確かにブラウザ上での利用の場合、画面のアプリID, フィールド絞り込み, クエリをそのまま利用するケースは少なくなさそうですね! ※若干の懸念点としてはfieldsについては画面に依存することで未定義プロパティアクセスの実行時エラーを引き起こしやすくなる可能性がありますね。
fields
すでに kintone.app.getQueryCondition() があるので、理想としてはfieldsやorder byについてもJS APIがある方が良さそうに思います。
kintone.app.getQueryCondition()
order by
rest-api-clientでも一覧設定取得APIでfields, filterCond, sortが取得できるので実現できそうですね。
filterCond
sort
JS APIについては社内にフィードバック、rest-api-clientでの対応はインターフェースも含めて検討させていただきます。
@mshrtsr コメントありかとうございます! また動きあったら教えてくださいませ〜。
No branches or pull requests
対象パッケージ
@kintone/rest-api-client
なぜ
アプリの一覧画面にボタンを設置して、
クリックすると、ビューの絞り込み条件・ソート条件をそのまま使ってデータ取得する
というケースがよくあります。
その際に、こんな風に書くわけですが、
fieldsとorderByがなかなか冗長になってしまうので、
「画面の条件を自動反映する」というオプションがあると、とても開発が楽になりそうです。
何を
たとえば、それぞれのプロパティにオブジェクト型も入れられるようにして、
こんな風にすると、アプリの設定を全自動で反映してくれるイメージです。
従来の型と混在も可能
従来の使いかたをオブジェクトで書くことも可能
もちろん、この通りの仕様で実装してくれなくても良いですが、
何かしらヒントになればと思います!
あるいは、kintone JavaScript API自体にこんな関数が追加されると
これだけでよくなるんですけどね。
ご検討、よろしくお願いします!
The text was updated successfully, but these errors were encountered: