List链表方式操作
list 链表操作
注意可以插入重复的数据
初始一个链表数据
bucket.upsert('name-list', ["revin"], function(err, result) {
if (err) throw err;
console.log(result);
});
Web UI 查看结果:

链表末尾加入数据
bucket.listAppend('name-list', "xiaoming", function(err, result) {
if (err) throw err;
console.log(result);
});
Web UI 查看结果:

链表开头加入数据
bucket.listPrepend('name-list', "xiaozhang", function(err, result) {
if (err) throw err;
console.log(result);
});
Web UI 查看结果:

获取链表中某个索引的值
bucket.listGet('name-list', 0, function(err, result) {
if (err) throw err;
console.log(result.value);
});
console结果
xiaozhang
获取链表的长度
bucket.listSize('name-list', function(err, result) {
if (err) throw err;
console.log(result.value);
});
console结果
3
修改链表索引位的值
bucket.listSet('name-list', 0 , "xiaowang" ,function(err, result) {
if (err) throw err;
console.log(result);
});
Web UI 查看结果:

Last updated
Was this helpful?