Set集合方式操作
set集合的的特点:集合内不能有重复值
初始一个集合数据
bucket.upsert('name-set', ["revin"], function(err, result) {
if (err) throw err;
console.log(result);
});
Web UI 查看结果:

集合中添加数据
bucket.setAdd('name-set', "xiaowang", function(err, result) {
if (err) throw err;
console.log(result);
});
Web UI 查看结果:

注意:不能集合不能有重复的值,所以添加重复值会报错.
判断集合中是否存在某值
bucket.setExists('name-set', "xiaowang", function(err, result) {
if (err) throw err;
console.log(result.value);
});
console结果:
true
获取集合大小
bucket.setSize('name-set', function(err, result) {
if (err) throw err;
console.log(result.value);
});
console结果:
2
删除集合中的值
bucket.setRemove('name-set', 'revin',function(err, result) {
if (err) throw err;
console.log(result.value);
});
Web UI 查看结果:

Last updated
Was this helpful?