我正在尝试从 sqlalchemy(SQlite) 迁移到使用 mongodb。我想要架构验证。我正在看 mongokit,但我想要一些类似于映射器的东西,这样它就可以从对象的属性中保存,而不是从字典中保存。
我想要一个映射器,这样我就可以在不修改现有对象的情况下使用它们。
最佳答案
另一个选项是MongoEngine . MongoEngine 的 ORM 与 Django 使用的 ORM 非常相似。
示例(来自教程):
class Post(Document):
title = StringField(max_length=120, required=True)
author = ReferenceField(User)
class TextPost(Post):
content = StringField()
class ImagePost(Post):
image_path = StringField()
class LinkPost(Post):
link_url = StringField()
https://stackoverflow.com/questions/2781682/
相关文章:
mongodb - $lookup 查找数组中的 ObjectId
mongodb - Meteor 应用程序 — 重置已部署应用程序的数据库
node.js - 如何在 mongodb-native findOne() 中使用变量作为字段名?
node.js - Mongoose findByIdAndUpdate 没有返回正确的模型
MongoDB select count(distinct x) on an indexed col
mongodb - 在 Mongoose/MongoDB 中创建多字段索引
mongodb - 无法验证到 mongo, "auth fails"