mirror of
https://github.com/swc-project/swc.git
synced 2024-12-23 05:32:09 +03:00
18 lines
498 B
TypeScript
18 lines
498 B
TypeScript
// Loaded from https://deno.land/x/dndb@0.2.4/src/methods/insert.js
|
|
|
|
|
|
import { writeFile } from '../storage.ts';
|
|
import { v1 } from "https://deno.land/std/uuid/mod.ts";
|
|
|
|
export default async (filename ,data) => {
|
|
if(Array.isArray(data)) {
|
|
data.forEach(async o => {
|
|
o._id = o._id || v1.generate();
|
|
await writeFile(filename, o);
|
|
});
|
|
} else {
|
|
data._id = data._id || v1.generate();
|
|
await writeFile(filename, data)
|
|
}
|
|
return data;
|
|
} |