赞
踩
上帖子使用云函数端云一体化开发计算十二生肖,此贴使用云数据库端云一体化开发计算十二生肖,在DevEco Studio可以完成端侧代码开发和云侧代码开发,一键部署云数据库,效果与之前使用云函数一样,计算获取方式不同。
创建端云一体化项目,这里就不介绍的,创建、部署云数据库官方详细教程 开发云数据库-开发云工程-端云一体化开发-应用/服务开发-DevEco Studio使用指南(HarmonyOS)-工具-HarmonyOS应用开发 端云一体化项目结构和之前不一样,多了CloudProgram模块, 下面介绍项目开发,先从云侧开发开始,再到端侧开发。
4.1 介绍云数据库目录结构
展开CloudProgram模块,展开clouddb目录,dataentry目录是存储数据条目文件,objecttype目录是存储对象类型文件,db-config.json自动生成,内容包含云数据库配置,目录结构如下图:
4.2 定义对象类型
右击objecttype目录,创建对象类型
- {
- "fields": [
- {
- "belongPrimaryKey": true,
- "fieldName": "idx",
- "fieldType": "Integer",
- "isNeedEncrypt": false,
- "notNull": true
- },
- {
- "belongPrimaryKey": false,
- "fieldName": "zodiacName",
- "fieldType": "String",
- "isNeedEncrypt": false,
- "notNull": false
- }
- ],
- "indexes": [
- {
- "indexName": "idxIndex",
- "indexList": [
- {
- "fieldName": "idx",
- "sortType": "ASC"
- }
- ]
- },
- {
- "indexName": "zodiacIndex",
- "indexList": [
- {
- "fieldName": "zodiacName",
- "sortType": "DESC"
- }
- ]
- }
- ],
- "objectTypeName": "ZodiacObject",
- "permissions": [
- {
- "rights": [
- "Read"
- ],
- "role": "World"
- },
- {
- "rights": [
- "Read",
- "Upsert"
- ],
- "role": "Authenticated"
- },
- {
- "rights": [
- "Read",
- "Upsert",
- "Delete"
- ],
- "role": "Creator"
- },
- {
- "rights": [
- "Read",
- "Upsert",
- "Delete"
- ],
- "role": "Administrator"
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。