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

json field issue, deserialisation not working automatic #1840

Open
abdulragib opened this issue Sep 28, 2024 · 0 comments
Open

json field issue, deserialisation not working automatic #1840

abdulragib opened this issue Sep 28, 2024 · 0 comments

Comments

@abdulragib
Copy link

abdulragib commented Sep 28, 2024

import {Model} from '@nozbe/watermelondb';
import {date, field, json} from '@nozbe/watermelondb/decorators';

export default class IndividualChatModel extends Model {
static table = 'individualChat';

@field('chat_id') chat_id;
@field('chat') chat;
@JSON('members', json => json) members; // JSON to store member IDs
@field('last_message') last_message;
@field('last_message_timestamp') last_message_timestamp;
@JSON('clear_chat_date', json => json) clear_chat_date;
@JSON('unread_count', json => json) unread_count; // JSON to store unread counts
@field('is_blocked') is_blocked;
@JSON('blockers', json => json) blockers; // JSON to store blockers
@JSON('muted', json => json) muted; // JSON to store mute status
@JSON('reports', json => json) reports; // JSON to store reports
@JSON('calls', json => json) calls; // JSON to store call IDs
@field('deleted') deleted;
@Date('created_at') created_at;
@Date('updated_at') updated_at;
}

when read the data , i got wrong json format , [{"_changed": "", "_status": "created", "blockers": "", "calls": "{newValue={is_group_call=false, recording_url=null, individual_chat_id=66f828963bf7e7fb763b3825, initiator=66e9e8035ac4685afc715c64, end_time=2024-09-28T16:05:26.425Z, call_id=call_66e9e3f75ac4685afc715c57_1727539526393, duration=00:02:50, start_time=2024-09-28T16:02:40.183Z, createdAt=2024-09-28T16:05:31.814Z, is_individual_call=true, __v=0.0, _id=66f8294b3bf7e7fb763b383c, call_type=Audio, status=cancelled, participants=[66e9e8035ac4685afc715c64, 66e9e3f75ac4685afc715c57], updatedAt=2024-09-28T16:05:31.814Z}, is_group_call=false, recording_url=null, individual_chat_id=66f828963bf7e7fb763b3825, initiator=66e9e8035ac4685afc715c64, end_time=2024-09-28T16:02:38.095Z, call_id=call_66e9e3f75ac4685afc715c57_1727539358041, duration=00:00:05, createdAt=2024-09-28T16:02:46.454Z, start_time=null, is_individual_call=true, __v=0.0, _id=66f828a63bf7e7fb763b3832, call_type=Audio, updatedAt=2024-09-28T16:02:46.454Z, participants=[66e9e8035ac4685afc715c64, 66e9e3f75ac4685afc715c57], status=cancelled}", "chat": "individual", "chat_id": "66f828963bf7e7fb763b3825", "clear_chat_date": [], "created_at": 1727539350889, "deleted": false, "id": "QKm05GPsEeavjCg2", "is_blocked": false, "last_message": "", "last_message_timestamp": "", "members": [[Object], [Object]], "muted": {}, "reports": "", "unread_count": {}, "updated_at": 0}]

json field used to automaic stored as string , those fields are array so i declare as string but when i fetch it it showing as string , how to fix it

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