@24hr/plattad 中文文档教程
Plattad
这是一个小包,旨在测试我们如何确保信息以正确的顺序保存到数据库中,而不需要交易。
它通过将所有内容写入日志(每次创建、更新、删除等)并在查询时合并数据来工作。
它支持快照,因此无需遍历所有日志即可合并数据,并且可以在快照后自动删除条目。
How to use
import plattad, {Plattad, PlattadResult} from 'plattad';
const test = () => {
const entity:Plattad = await plattad(options);
const options = {
connectionString: 'sqlite::memory:',
logging: false,
};
await entity.create('foo', 1, { foo: 'riker', bar: 1 });
await entity.update('foo', 2, { foo: 'picard' });
const entry: PlattadResult | null = await entity.get('foo');
console.log(entry);
/*
{
data: {
foo: 'picard',
bar: 1,
}
}
.... and some more meta data
*/
});
test();
#
Plattad
This is a small package that is designed to test how we can secure that information has been saved in the right order to a database without the need of transactions.
It works by writing everything to a log, (every create, update, delete etc) and mergin the data when querying it.
It has support for snapshots, so that merged data is fecthed without going trough all logs, and it can auto delete entries after snapshooting.
How to use
import plattad, {Plattad, PlattadResult} from 'plattad';
const test = () => {
const entity:Plattad = await plattad(options);
const options = {
connectionString: 'sqlite::memory:',
logging: false,
};
await entity.create('foo', 1, { foo: 'riker', bar: 1 });
await entity.update('foo', 2, { foo: 'picard' });
const entry: PlattadResult | null = await entity.get('foo');
console.log(entry);
/*
{
data: {
foo: 'picard',
bar: 1,
}
}
.... and some more meta data
*/
});
test();
#