一、概念

1. 小程序云开发,让前端程序员拥有后端的能力
2. 云函数 (nodejs)
3. 云数据库 (mogodb)
4. 云存储
5. 前端写好云函数 -> 上传到云服务器 ->实现自定云部署
6. 前端去调用云函数=>间接通过云函数对数据库的操作
7. 前端=》全栈

二、使用云开发的注意点

1. 在app.js

在这里插入图片描述

2. 云函数index.js 定义id

在这里插入图片描述

3. 云id来自
云开发->概览->环境id

在这里插入图片描述

4. 选择环境

在这里插入图片描述

5. 上传并部署

在这里插入图片描述

6. 增量上传

在这里插入图片描述

三、云数据库的创建

1. 创建集合-》添加记录

在这里插入图片描述
2.

四、云函数的定义与基本使用

01 右键创建云函数

在这里插入图片描述

02 在页面中调用云函数
wx.cloud.callFunction({name,data})

在这里插入图片描述

03 在云函数 如何操作云数据
初始化  var db = cloud.database();
	
获取  var data = await db.collection("feedback").get()
	
添加  var  data = await db.collection("feedback").add(data:{添加数据})	

五、云数据库的常用api

1.databaseMigrateImport 数据库导入

请求地址

POST https://api.weixin.qq.com/tcb/databasemigrateimport?access_token=ACCESS_TOKEN
  
详细说明看 https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-http-api/database/databaseMigrateImport.html
2.databaseMigrateExport 数据库导出

请求地址

POST https://api.weixin.qq.com/tcb/databasemigrateexport?access_token=ACCESS_TOKEN

详细说明看https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-http-api/database/databaseMigrateExport.html
3.databaseMigrateQueryInfo 数据库迁移状态查询

请求地址

POST https://api.weixin.qq.com/tcb/databasemigratequeryinfo?access_token=ACCESS_TOKEN

详细说明看https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-http-api/database/databaseMigrateQueryInfo.html
4.updateIndex 变更数据库索引

请求地址

POST https://api.weixin.qq.com/tcb/updateindex?access_token=ACCESS_TOKEN

详细说明看https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-http-api/database/updateIndex.html
5.databaseCollectionAdd 新增集合

请求地址

POST https://api.weixin.qq.com/tcb/databasecollectionadd?access_token=ACCESS_TOKEN

详细说明看https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-http-api/database/databaseCollectionAdd.html
6.databaseCollectionDelete 删除集合

请求地址

POST https://api.weixin.qq.com/tcb/databasecollectiondelete?access_token=ACCESS_TOKEN

详细说明看https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-http-api/database/databaseCollectionDelete.html
7.databaseCollectionGet 数据库导出

请求地址

 https://api.weixin.qq.com/tcb/databasecollectionget?access_token=ACCESS_TOKEN

详细说明看https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-http-api/database/databaseCollectionGet.html
8.databaseAdd 数据库插入记录

请求地址

POST https://api.weixin.qq.com/tcb/databaseadd?access_token=ACCESS_TOKEN

详细说明看https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-http-api/database/databaseAdd.html
9.databaseDelete 数据库删除记录

请求地址

POST https://api.weixin.qq.com/tcb/databasedelete?access_token=ACCESS_TOKEN

详细说明看https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-http-api/database/databaseDelete.html
10.databaseUpdate 数据库更新记录

请求地址

POST https://api.weixin.qq.com/tcb/databaseupdate?access_token=ACCESS_TOKEN

详细说明看https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-http-api/database/databaseUpdate.html
11.databaseQuery 数据库查询记录

请求地址

 POST https://api.weixin.qq.com/tcb/databasequery?access_token=ACCESS_TOKEN

详细说明看https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-http-api/database/databaseQuery.html
7.databaseCollectionGet 数据库导出

请求地址

 https://api.weixin.qq.com/tcb/databasecollectionget?access_token=ACCESS_TOKEN

详细说明看https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-http-api/database/databaseCollectionGet.html
7.databaseCollectionGet 数据库导出

请求地址

 https://api.weixin.qq.com/tcb/databasecollectionget?access_token=ACCESS_TOKEN

详细说明看https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-http-api/database/databaseCollectionGet.html
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐