我是 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)
据我所知.. …