简体   繁体   English

在数据库中存储表单模式和功能

[英]Storing form schemas and functions in a Database

My colleagues and I are building a web app with a relatively complex back end. 我和我的同事正在构建一个具有相对复杂后端的Web应用程序。 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. 模式是JSON对象,可在客户端动态创建表单。 When the data in the form is submitted the linked functions may do a variety of different things with that data. 提交表单中的数据时,链接的函数可能会对该数据执行各种不同的操作。

Currently these form schemas and linked functions are hosted in a private repo on GitHub. 当前,这些表单模式和链接函数托管在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? 我知道mongodb不会很麻烦地存储表单模式,但是函数和函数依赖项又如何呢?

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. 如果要在后端(节点)上使用该代码,请评估它或创建一个新函数Function(functionString)并在服务器端进行验证。 /edit Or put each schema in a file and request it server/client side when you need it. / edit或将每个模式放在文件中,并在需要时在服务器/客户端请求它。 Making a DB round for something like this is expensive. 围绕这样的事情进行数据库访问很昂贵。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM