当前位置:   article > 正文

#如何创新玩转HarmonyOS开发#端云一体化开发计算十二生肖-云数据库_harmony os云数据库

harmony os云数据库

1. 前言

上帖子使用云函数端云一体化开发计算十二生肖,此贴使用云数据库端云一体化开发计算十二生肖,在DevEco Studio可以完成端侧代码开发和云侧代码开发,一键部署云数据库,效果与之前使用云函数一样,计算获取方式不同。

2. 真机效果

3. 讲解

创建端云一体化项目,这里就不介绍的,创建、部署云数据库官方详细教程 开发云数据库-开发云工程-端云一体化开发-应用/服务开发-DevEco Studio使用指南(HarmonyOS)-工具-HarmonyOS应用开发 端云一体化项目结构和之前不一样,多了CloudProgram模块, 下面介绍项目开发,先从云侧开发开始,再到端侧开发。

4. 云侧开发

4.1 介绍云数据库目录结构

展开CloudProgram模块,展开clouddb目录,dataentry目录是存储数据条目文件,objecttype目录是存储对象类型文件,db-config.json自动生成,内容包含云数据库配置,目录结构如下图:

4.2 定义对象类型

     右击objecttype目录,创建对象类型

  1. {
  2. "fields": [
  3. {
  4. "belongPrimaryKey": true,
  5. "fieldName": "idx",
  6. "fieldType": "Integer",
  7. "isNeedEncrypt": false,
  8. "notNull": true
  9. },
  10. {
  11. "belongPrimaryKey": false,
  12. "fieldName": "zodiacName",
  13. "fieldType": "String",
  14. "isNeedEncrypt": false,
  15. "notNull": false
  16. }
  17. ],
  18. "indexes": [
  19. {
  20. "indexName": "idxIndex",
  21. "indexList": [
  22. {
  23. "fieldName": "idx",
  24. "sortType": "ASC"
  25. }
  26. ]
  27. },
  28. {
  29. "indexName": "zodiacIndex",
  30. "indexList": [
  31. {
  32. "fieldName": "zodiacName",
  33. "sortType": "DESC"
  34. }
  35. ]
  36. }
  37. ],
  38. "objectTypeName": "ZodiacObject",
  39. "permissions": [
  40. {
  41. "rights": [
  42. "Read"
  43. ],
  44. "role": "World"
  45. },
  46. {
  47. "rights": [
  48. "Read",
  49. "Upsert"
  50. ],
  51. "role": "Authenticated"
  52. },
  53. {
  54. "rights": [
  55. "Read",
  56. "Upsert",
  57. "Delete"
  58. ],
  59. "role": "Creator"
  60. },
  61. {
  62. "rights": [
  63. "Read",
  64. "Upsert",
  65. "Delete"
  66. ],
  67. "role": "Administrator"
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/720150
推荐阅读
相关标签
  

闽ICP备14008679号