当前位置:网站首页>0 foundation a literature club low code development member management applet (III)
0 foundation a literature club low code development member management applet (III)
2022-06-24 07:06:00 【Low code preacher】
1 Third articles : Recharge record function development
1.1 Last article review
In the previous article, we implemented the member recharge record function , Encountered a BUG As a result, the new functions are not easy to use , And recorded .
1.2 This paper introduces
This article mainly introduces the development of recharge recording function , During daily business operation , It is not enough just to increase the balance , We also need to record the recharge , Convenient for members to view .
According to the traditional development method, we generally need to design the master sub table , The master table records the basic information of members , The sub table records the recharge information of members . But we don't do this in low code development , Why? ? Because we are a document database , There is no need to follow the traditional design thinking .
How does it work ? Just listen to me .
1.3 Modify the data source
We add an array field to the member data source , Used to record recharge information
Array fields are not enough , We also need to add business logic , So you need to use the custom method of the data source
Note that the custom method needs to be tested first , After passing the test, you can develop the page
Specific method
module.exports = async function (params, context) {
const newParams = Object.assign({}, params, {
updatedAt: Date.now(),
});
delete newParams.createdAt;
delete newParams._id;
const _ = context.database.command;
console.log(params.account);
let money=parseInt(params.account)
const result = await context.collection.doc(params._id).update({
account:_.inc(money),
addrecord:_.push({
money:params.account,
adddate:Date.now()
})
});
return { updated: result.updated };
}
Here we use the array operation of cloud development _.push, Each time the balance is increased, a new record is added to the array
{
money:params.account,
adddate:Date.now()
}
A pair of braces denotes an object , There are two properties in the object , They are the amount of this recharge and the current time , After the method is added, we can develop the page function
1.4 Page function development
The recharge function of the page is the same as that in the previous section , We just modified the method of recharging , Added the function of recharge record
1.5 Preview release
Click the preview function and we can actually experience it
1.6 The next trailer
We will continue to develop the function in the next article , Develop the function of consumption , See you next time .
边栏推荐
- Online font converter what is the meaning of font conversion
- JVM调试工具-jvisualvm
- 【云驻共创】华为云HCIA-IoT V2.5培训系列内容之物联网概览
- About Stacked Generalization
- File system notes
- typescript vscode /bin/sh: ts-node: command not found
- 潞晨科技获邀加入NVIDIA初创加速计划
- 智能视觉组A4纸识别样例
- JVM调试工具-jmap
- Localized operation on cloud, the sea going experience of kilimall, the largest e-commerce platform in East Africa
猜你喜欢

.NET7之MiniAPI(特别篇) :Preview5优化了JWT验证(上)

潞晨科技获邀加入NVIDIA初创加速计划

Oracle SQL comprehensive application exercises

With a goal of 50million days' living, pwnk wants to build a "Disneyland" for the next generation of young people

Rockscache schematic diagram of cache operation

Typora charges? Build vs Code markdown writing environment

Computing power and intelligence of robot fog

记录--关于JSP前台传参数到后台出现乱码的问题

Challenges brought by maker education to teacher development

RealNetworks vs. 微软:早期流媒体行业之争
随机推荐
Arduino raised $32million to enter the enterprise market
Virtual file system
How do I check the IP address? What is an IP address
Oracle SQL comprehensive application exercises
What is the OSI seven layer model? What is the role of each layer?
About Stacked Generalization
Cloud native high availability and Disaster Recovery Series (I): pod break up scheduling
云监控系统 HertzBeat v1.1.0 发布,一条命令开启监控之旅!
JVM调试工具-jmap
Domain name purchase method good domain name selection principle
Online font converter what is the meaning of font conversion
CloudCompare&PCL 点云裁剪(基于裁剪盒)
Another double win! Tencent's three security achievements were selected into the 2021 wechat independent innovation achievements recommendation manual
Database stored procedure begin end
How long does the domain name filing take and what materials need to be prepared
C语言学生管理系统——可检查用户输入合法性,双向带头循环链表
How to register the cloud service platform and what are the advantages of cloud server
Typora收费?搭建VS Code MarkDown写作环境
oracle sql综合运用 习题
雲監控系統 HertzBeat v1.1.0 發布,一條命令開啟監控之旅!