# 查詢單個(gè)數(shù)據(jù)庫(kù)某個(gè)特定的數(shù)據(jù)
? wx.cloud.database().collection('goods').where({name:"橘子"}).get()
? .then(res=>{
? ? console.log(res)
? ? })
## doc單條數(shù)據(jù)查詢(_id)
```javascript
wx.cloud.database().collection('goods').doc("8655d51b639873f701956aea1b9e3ba4").get()
? .then(res=>{
? ? ? console.log(res)
? ? ? this.setData({
? ? ? ? list:res.data
? ? ? })
? ? })
? ? .catch(err=>{
? ? ? console.log(err)
? ? })
```
## 數(shù)據(jù)添加add
```javascript
? wx.cloud.database().collection("goods")
? ? .add({
? ? ? data:{
? ? ? ? name:"西瓜",
? ? ? ? price:20
? ? ? }
? ? })
? ? .then(res=>{
? ? ? console.log(res)
? ? })
? ? .catch(err=>{
? ? console.log("添加失敗",err)
? ? })
```
。
## 修改數(shù)據(jù)updata 需要用doc查詢
```javascript
wx.cloud.database().collection("goods").doc("e707b2f7639888b501702c2025ae376d")
? ? .update({
? ? ? data:{
? ? ? ? price:100
? ? ? }
? ? })
? ? .then(res=>{
? ? ? console.log(res)
? ? })
? ? .catch(err=>{
? ? console.log("添加失敗",err)
? ? })
```
## 刪除數(shù)據(jù)
```javascript
wx.cloud.database().collection("goods").doc("e707b2f7639888b501702c2025ae376d")
? ? .remove()
? ? .then(res=>{
? ? console.log(res)
? })
? .catch(err=>{
? ? console.log("刪除失敗",err)
? })
```