XuqmGroup-RNSDK/packages/im/src/db/schema.ts

41 行
1.5 KiB
TypeScript

import { appSchema, tableSchema } from '@nozbe/watermelondb'
export const imDbSchema = appSchema({
version: 2,
tables: [
tableSchema({
name: 'im_conversations',
columns: [
{ name: 'app_id', type: 'string', isIndexed: true },
{ name: 'target_id', type: 'string', isIndexed: true },
{ name: 'chat_type', type: 'string' },
{ name: 'last_msg_id', type: 'string', isOptional: true },
{ name: 'last_msg_content', type: 'string', isOptional: true },
{ name: 'last_msg_type', type: 'string', isOptional: true },
{ name: 'last_msg_time', type: 'number' },
{ name: 'unread_count', type: 'number' },
{ name: 'is_muted', type: 'boolean' },
{ name: 'is_pinned', type: 'boolean' },
{ name: 'updated_at', type: 'number' },
],
}),
tableSchema({
name: 'im_messages',
columns: [
{ name: 'server_id', type: 'string', isIndexed: true },
{ name: 'app_id', type: 'string', isIndexed: true },
{ name: 'conversation_id', type: 'string', isIndexed: true },
{ name: 'from_user_id', type: 'string' },
{ name: 'to_id', type: 'string' },
{ name: 'chat_type', type: 'string' },
{ name: 'msg_type', type: 'string' },
{ name: 'content', type: 'string' },
{ name: 'status', type: 'string' },
{ name: 'mentioned_user_ids', type: 'string', isOptional: true },
{ name: 'server_created_at', type: 'number' },
{ name: 'synced_at', type: 'number' },
],
}),
],
})