JSON fields are not returned as an object (when stored as a string)
- 主要言語
- JavaScript
- スター
- 2k
- フォーク
- 238
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
At the moment i need to use for every JSON field this code before storing an item:
``` javascript
User.validate('settings', function(err) {
if (typeof this.settings !== 'object') {
try {
this.settings= JSON.parse(this.settings);
} catch (e) {
err();
}
}
}, {
message: 'Invalid JSON'
});
```
Would be nice if there would exist a function that does that automatically and throws an error when the field can't be converted to an object.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
Look at the schema definitions for JSON fields in jugglingdb's adapters (like mysql, postgresql). The issue is about automatic JSON parsing when a string is stored. Start by finding where field types are defined and how data is serialized/deserialized. Check existing validation or coercion logic. The goal is to add a function that automatically parses JSON strings to objects and throws on invalid JSON, eliminating the need for manual validation.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, mongodb, mysql, nodejs, postgresql, redis, sqlite
- 領域
- backend, database
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 45/100