1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-11-28 04:04:58 +03:00

refactor(bridge/nodejs): rename insert to create

This commit is contained in:
louistiti 2023-05-11 20:59:26 +08:00
parent 8e55c481d4
commit af2a124165
2 changed files with 8 additions and 8 deletions

View File

@ -27,11 +27,11 @@ export class Memory {
}
/**
* Insert record to memory
* Create record
* @param record
* @example insertOne({ id: 0, title: 'hello world' })
* @example create({ id: 0, title: 'hello world' })
*/
public async insertOne<T>(record: T): Promise<T> {
public async create<T>(record: T): Promise<T> {
this.memory.data[this.name].push(record)
await this.memory.write()
@ -40,11 +40,11 @@ export class Memory {
}
/**
* Insert records to memory
* Create records
* @param records
* @example insertMany([{ id: 0, title: 'hello world' }, { id: 1, title: 'hello world' }])
* @example createMany([{ id: 0, title: 'hello world' }, { id: 1, title: 'hello world' }])
*/
public async insertMany<T>(records: T[]): Promise<T[]> {
public async createMany<T>(records: T[]): Promise<T[]> {
this.memory.data[this.name].push(...records)
await this.memory.write()

View File

@ -10,7 +10,7 @@ export const run: ActionFunction = async function () {
const posts = await new Memory('posts').load()
// const sections = await new Memory('sections').load()
await posts.insertOne({
await posts.create({
id: 0,
title: 'hello world',
content: 'hello world',
@ -20,7 +20,7 @@ export const run: ActionFunction = async function () {
createdAt: Date.now()
})
await posts.insertMany([
await posts.createMany([
{
id: 1,
title: 'hello world',