微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

从存储在nedb文档中的数组中删除项目

如何解决从存储在nedb文档中的数组中删除项目

我将此数组存储在我的nedb实例中:

proxy: Array(10)
0: {referrer: true,anonymity: "elite",country: "IN",ipPort: "150.129.115.118:48071",userAgent: true,…}
1: {get: null,userAgent: null,ipPort: "51.254.237.77:3129",port: "3129",…}
2: {port: "43399",referrer: true,protocol: "http",get: true,https: true,…}
3: {cookies: true,ip: "78.29.42.10",post: true,…}
4: {ip: "179.124.242.34",country: "BR",cookies: true,…}
5: {referrer: true,city: null,ip: "41.60.237.83",…}
6: {post: true,country: "TH",…}
7: {post: true,port: "8080",ip: "189.85.89.76",…}
8: {ip: "36.72.155.66",…}
9: {ipPort: "51.15.98.146:3128",port: "3128",…}

我想从中删除一个条目,但是我找不到正确的方法,我尝试使用以下代码

    db.proxyList.remove({ proxy: rnd }).then( (doc) => {
      console.log(doc);
    });

,但它将始终返回0,并且要删除的条目不会被删除。我正在使用存储在var rnd内部并以这种方式生成随机值选择数组索引:let rnd = Math.floor(Math.random() * list[0].proxy.lenght)。如何使用数组索引删除所需的项目?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。