小编Jud*_*y2K的帖子

如何在 Rust 中实现 MongoDB 模式和业务逻辑?

我是 Rust 新手,也是 MongoDB 的频繁用户。我通常使用node.js+ Mongoose ODM

RUST 中是否有任何 MongoDB ODM 可以像 Mongoose ODM 一样实现自定义模式和业务逻辑挂钩?或者我需要自己在 Rust 的类型系统中实现它?

这是猫鼬的一个例子

    const schema = kittySchema = new Schema(..);

    // they implement the 'meow' method in the Kitty Schema
    schema.method('meow', function () {
        console.log('meeeeeoooooooooooow');
    })
    
    // so anytime a Kitty schema instance is created
    const Kitty = mongoose.model('Kitty', schema);

    const fizz = new Kitty;
    
    // fizz as the instance of Kitty Schema automatically has meow() method
    fizz.meow(); // outputs: meeeeeooooooooooooow
Run Code Online (Sandbox Code Playgroud)

据我所知.. …

mongodb rust

2
推荐指数
1
解决办法
579
查看次数

标签 统计

mongodb ×1

rust ×1