跳到主要内容

模型修改

创建数据

const todo = new Todo();
todo.title = 'test';
await todo.save();

修改数据

todo.title = 'test';
await todo.save();

删除数据

todo.title = 'test';
await todo.remove();

批量创建

const todos: Todo[] = [];
for (let i = 0; i < 100; i++) {
const todo = new Todo();
todo.title = 'todo_' + i;
todos.push(todo);
}
await rxdb.entityManager.saveMany(todos);

批量保存

for (const todo of todos) {
todo.completed = toggle;
}
await rxdb.entityManager.saveMany(todos);

批量删除

for (const todo of todos) {
todo.completed = toggle;
}
await rxdb.entityManager.removeMany(todos);