请问用云开发来做程序,对数据库的操作是直接写在前端js文件里合适,还是全都用云端调用比较合适呢?

小程序 文章 2022-04-29 11:40 472 0 全屏看文

AI助手支持GPT4.0

请问用云开发来做程序,对数据库的操作是直接写在前端js文件里合适,还是全都用云端调用比较合适呢?May I ask if you use cloud development to make programs, is it appropriate to write the database operations directly in the front-end js files, or is it more appropriate to use the cloud to call them all?

请问用云开发来做程序,对数据库的操作是直接写在前端js文件里合适,还是全都用云端调用比较合适呢?

新手开发,现在在用微信云开发做一套带后台管理的系统,想寻求一下大佬们的建议。

如题,

在用云开发的过程中,遇到过多表联查,一定要用到云函数才能够实现,这时候前端只需要调用云函数,数据库访问及逻辑操作均在云函数中实现。

但是像一般的,简单的增删查改,不涉及多表操作的,以及对文件或文件夹的操作,直接在前端的js里写数据库操作,业务逻辑等等比较合适,

还是全都写到云函数里好一些呢?两种写法有什么区别?优势在哪里?

Novice developers are now using wechat cloud to develop a system with background management. I want to seek the suggestions of the bosses. For example, in the process of cloud development, if you encounter too many table joint queries, you must use cloud functions to realize them. At this time, the front end only needs to call cloud functions, and database access and logical operations are realized in cloud functions. However, it's more appropriate to simply add, delete, query and modify, do not involve multi table operations, and file or folder operations, and directly write database operations and business logic in the front-end JS. Is it better to write them all in the cloud function? What is the difference between the two writing methods? What are the advantages?

回答:

dreamhunter:

权限不同,云函数是管理员权限。一些敏感操作只能用云函数实现,不涉及权限的前端做比较方便

订阅happiness:

没有啥区别。如果你小程序里有多处用到同一个获取数据库的内容的方法,建议写成云函数,这个就相当于util里的公共函数,多个地方需要调用到。如果只有一次调用的 建议页面单独调用。

卖女孩的小男孩:

写到云函数里,

需要修改的时候不需要重新提审。

一诺茨k:不好意思,请问重新提审是指什么?
卖女孩的小男孩:oh~我以为你说的是小程序....

-EOF-

AI助手支持GPT4.0