feat(infra): doc properties by orm (#8382)

create new orm table docConfiguration

move primary store to docConfiguration
This commit is contained in:
EYHN
2024-10-07 12:25:47 +00:00
parent f5c49a6ac9
commit c26df2e069
16 changed files with 551 additions and 80 deletions
@@ -0,0 +1,31 @@
import { describe, expect, test } from 'vitest';
import { Doc as YDoc, Map as YMap } from 'yjs';
import { yjsObserveByPath } from '../yjs-observable';
describe('yjs observable', () => {
test('basic', async () => {
const ydoc = new YDoc();
let currentValue: any = false;
yjsObserveByPath(ydoc.getMap('foo'), 'key.subkey').subscribe(
v => (currentValue = v)
);
expect(currentValue).toBe(undefined);
ydoc.getMap('foo').set('key', new YMap([['subkey', 'xxxzzz']]));
expect(currentValue).toBe('xxxzzz');
(ydoc.getMap('foo').get('key') as YMap<string>).set('subkey', 'yyy');
expect(currentValue).toBe('yyy');
(ydoc.getMap('foo').get('key') as YMap<string>).delete('subkey');
expect(currentValue).toBe(undefined);
(ydoc.getMap('foo').get('key') as YMap<string>).set('subkey', 'yyy');
ydoc.getMap('foo').delete('key');
expect(currentValue).toBe(undefined);
ydoc.getMap('foo').set('key', 'text');
expect(currentValue).toBe(undefined);
});
});