getSyncType()
function getSyncType(metadata, globalSync?): RepositorySyncType;
Defined in: packages/rxdb/src/version/sync-type-utils.ts:81
从 EntityMetadata 获取同步类型
Parameters
| Parameter | Type | Description |
|---|---|---|
metadata | EntityMetadata | 实体元数据 |
globalSync? | SyncOptions | 全局同步配置(可选,作为回退) |
Returns
同步类型
Throws
如果 sync.type === 'filter'(不支持)
Example
// Full sync (双向同步)
const metadata = {
sync: {
type: SyncType.Full,
local: { adapter: 'sqlite' },
remote: { adapter: 'supabase' }
}
};
getSyncType(metadata); // 'full'
// Remote only (只读远程)
const metadata = {
sync: {
type: SyncType.None,
remote: { adapter: 'supabase' }
}
};
getSyncType(metadata); // 'remote'
// Local only (只本地)
const metadata = {
sync: {
type: SyncType.None,
local: { adapter: 'sqlite' }
}
};
getSyncType(metadata); // 'local'
// No sync (系统表)
const metadata = { sync: undefined };
getSyncType(metadata); // 'none'
// 使用全局配置回退
const metadata = { sync: undefined };
const globalSync = { type: SyncType.Full, local: {...}, remote: {...} };
getSyncType(metadata, globalSync); // 'full'