【问题标题】:Is there a mongoose-like library for front-end?前端是否有类似猫鼬的库?
【发布时间】:2018-10-25 16:47:58
【问题描述】:

我并不是说前端会直接联系数据库。我只是希望有一个工具可以将高级 db 操作转换为低级 http 命令。然后app server就可以对db server进行相应的处理了。

import React from 'react'
import X from 'X'
class Demo extends React.Component{
    constructor(){
        super();
        this.state={result:null}
        let schema=new X.Schema({title:String});
        this.model=X.model('blob',schema)
    }
    handleClick=()=>{
        this.model.create({titile:this.input.value}).then(()=>{
            this.setState({result:"new blog stored in the remote db successfully"})
        })
    }
    render(){
        return <div>
            <input ref=(input)=>{this.input=input} />
            <button onClick={this.handleClick}>submit</button>
            <div>{this.state.result}</div>
        </div>
    }
}

【问题讨论】:

    标签: reactjs frontend


    【解决方案1】:

    我不确定这样的东西是否存在,即使不存在,我也认为它会对网站构成巨大的安全威胁。

    但是,有一些很好的工具可以创建模式,例如从响应到后端的查询。 考虑使用 GraphQL 和 Firebase,当然还有其他工具和服务,但我发现这些是最受欢迎的,你会在网上找到很多关于如何将它们与 react 一起使用的教程(例如如here 和here)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-08
      • 1970-01-01
      • 1970-01-01
      • 2022-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多