在数据库中存储表单模式和功能 [英] Storing form schemas and functions in a Database

查看:71
本文介绍了在数据库中存储表单模式和功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我和我的同事正在构建一个具有相对复杂后端的Web应用程序.在不放弃产品思想的情况下,我们有数百种表单架构及其返回函数,在提交表单时会调用它们.模式是JSON对象,可在客户端动态创建表单.提交表单中的数据时,链接的函数可能会对这些数据执行各种不同的操作.

My colleagues and I are building a web app with a relatively complex back end. Without giving away the product idea, we have several hundred form schemas paired with their return functions which are called when the form is submitted. The schemas are JSON objects which dynamically create a form on the client side. When the data in the form is submitted the linked functions may do a variety of different things with that data.

当前,这些表单模式和链接函数托管在GitHub上的私有仓库中.这是最好的方法吗?还是可以将它们保留在诸如mongodb的数据库中?

Currently these form schemas and linked functions are hosted in a private repo on GitHub. Is this the best way to go or could they be persisted in a database such as mongodb?

我知道mongodb不会很麻烦地存储表单模式,但是函数和函数依赖项又如何呢?

I understand mongodb will have no trouble storing the form schemas but what about the functions and the functions dependencies?

推荐答案

将其存储为数据库(作为字符串),并在客户端请求时将其提供给客户端(将转换为函数).如果要在后端(节点)上使用该代码,请评估它或创建一个新函数Function(functionString)并在服务器端进行验证. /编辑 或将每个模式放在文件中,并在需要时在服务器/客户端请求它.围绕这样的事情进行数据库访问很昂贵.

Store it into the database (as a string) and give it to the client when he requests it (will turn into a function). If you want to use that code on the backend (node), you'd eval it or make a function new Function(functionString) and do your validating on the server side as well. /edit Or put each schema in a file and request it server/client side when you need it. Making a DB round for something like this is expensive.

这篇关于在数据库中存储表单模式和功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆