在v1 版本中我们讲述了 基础版的应用
JAVASCRIPT 前端数据库-V1--仙盟数据库架构-—-—仙盟创梦IDE-CSDN博客
接下载我们做一个更复杂的的其他场景
由于,V1查询字段必须 id
接下来我们修改了了代码
JAVASCRIPT 前端数据库-V2--仙盟数据库架构-—-—仙盟创梦IDE-CSDN博客
由于,V2只能查询1个字段
接下来我们修改了了代码
JAVASCRIPT 前端数据库-V3--仙盟数据库架构-—-—仙盟创梦IDE-CSDN博客
v3 由于没有 清空 操作,多选
接下来我们修改了了代码
/*仙盟创梦数据太虚 2025-6-7*/
var 仙盟创梦数据太虚_STORAGE_PREFIX = "未来之窗仙盟数据";
class 仙盟创梦数据太虚 {
constructor(神通) {
this.神通 = `${仙盟创梦数据太虚_STORAGE_PREFIX}${神通}`;
this.灵蕴阁 = this.加载数据();
}
加载数据() {
return JSON.parse(localStorage.getItem(this.神通)) || [];
}
保存() {
localStorage.setItem(this.神通, JSON.stringify(this.灵蕴阁));
}
新增(仙纪) {
this.灵蕴阁.push(仙纪);
this.保存();
return 仙纪;
}
更新(param1,value1,param2,value2, updatedItem) {
const 灵引 = this.灵蕴阁.findIndex(仙纪 => 仙纪 => 仙纪[param1] == value1 && 仙纪[param2] == value2);
if (灵引!== -1) {
this.灵蕴阁[灵引] = {...this.灵蕴阁[灵引],...updatedItem };
this.保存();
}
return this.灵蕴阁[灵引];
}
删除(param1,value1,param2,value2) {
this.灵蕴阁 = this.灵蕴阁.filter(仙纪 => 仙纪[param1] != value1 && 仙纪[param2] != value2);
this.保存();
}
读取(param1,value1,param2,value2) {
return this.灵蕴阁.find(仙纪 => 仙纪[param1] == value1 && 仙纪[param2] == value2);
}
选择(param1,value1,param2,value2) {
return this.灵蕴阁.filter(仙纪 => 仙纪[param1] === value1 && 仙纪[param2] === value2);
}
清空() {
//const 清空={};
this.灵蕴阁 =[];
this.保存();
}
}
阿雪技术观
让我们积极投身于技术共享的浪潮中,不仅仅是作为受益者,更要成为贡献者。无论是分享自己的代码、撰写技术博客,还是参与开源项目的维护和改进,每一个小小的举动都可能成为推动技术进步的巨大力量
Embrace open source and sharing, witness the miracle of technological progress, and enjoy the happy times of humanity! Let's actively join the wave of technology sharing. Not only as beneficiaries, but also as contributors. Whether sharing our own code, writing technical blogs, or participating in the maintenance and improvement of open source projects, every small action may become a huge force driving technological progress.