I'd like to write a mongoORM nimble package similar to python's MongoEngine library. MongoORM would, ideally, depend on nimongo for the underlying access to MongoDB. mongoORM's purpose is to overlay client-side type checking and validation on collections.
Essentially, the package module would use nim's support for compile-time macros, generics, and templates to create a domain-specific language (DSL). Essentially allowing something like:
# Create new Mongo client via nimongo
var m = newMongo().slaveOk(true).allowPartial(false)
# define a document using DSL
document Page(m):
name string
posts seq[int]:
nil_allowed = true
contact email:
required = true
# now I'll use it
var mydoc = Page().new()
mydoc.name = "joe"
mydoc.posts = [3, 9, nil, 2]
mydoc.contact = "test@example.com"
mydoc.save()
# an invalid field, such as invalid email address generates a MongoORMError
But, before I go writing this beast, I wanted to make sure:
I'm not duplicating someone else's effort that you know of, and
you can't think of any downsides to using (and being dependent on) nimongo in this way.
I'd like to write a
mongoORM
nimble package similar to python's MongoEngine library. MongoORM would, ideally, depend onnimongo
for the underlying access to MongoDB.mongoORM
's purpose is to overlay client-side type checking and validation on collections.Essentially, the package module would use nim's support for compile-time macros, generics, and templates to create a domain-specific language (DSL). Essentially allowing something like:
But, before I go writing this beast, I wanted to make sure:
nimongo
in this way.