> For the complete documentation index, see [llms.txt](https://couchbase.shujuwajue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://couchbase.shujuwajue.com/shi-yong-node-js-ke-hu-duan/ji-ben-cao-zuo/list-lian-biao-cao-zuo.md).

# List链表方式操作

## list 链表操作

> 注意可以插入重复的数据

初始一个链表数据

```sql
bucket.upsert('name-list', ["revin"], function(err, result) {
    if (err) throw err;
    console.log(result);
});
```

Web UI 查看结果:

![](/files/-LfnTMk-g4INi3YtgVIm)

## 链表末尾加入数据

```sql
bucket.listAppend('name-list', "xiaoming", function(err, result) {
    if (err) throw err;
    console.log(result);
});
```

Web UI 查看结果:

![](/files/-LfnTMk1PDZtiX06IZJJ)

## 链表开头加入数据

```sql
bucket.listPrepend('name-list', "xiaozhang", function(err, result) {
    if (err) throw err;
    console.log(result);
});
```

Web UI 查看结果:

![](/files/-LfnTMk35sDdvO695WMJ)

## 获取链表中某个索引的值

```sql
bucket.listGet('name-list', 0, function(err, result) {
    if (err) throw err;
    console.log(result.value);
});
```

console结果

```
xiaozhang
```

## 获取链表的长度

```sql
bucket.listSize('name-list', function(err, result) {
    if (err) throw err;
    console.log(result.value);
});
```

console结果

```
3
```

## 修改链表索引位的值

```sql
bucket.listSet('name-list', 0 , "xiaowang" ,function(err, result) {
    if (err) throw err;
    console.log(result);
});
```

Web UI 查看结果:

![](/files/-LfnTMk5a6_nUsQZJ4pJ)
