Do any mongodb ORM modules allow you to create aliases?

I just watched this: http://blog.mongodb.org/post/38467892360/mongodb-schema-design-insights-and-tradeoffs-from

One suggestion that came out of the conversation: in documents that will be repeated many times, try to make the field names as small as possible:

Reduce the size of the collection, always using short field names as a convention. This will help you save memory over time.

Select "u" above "publicationUrl". It makes sense if you are talking about millions of lines. However, there is a big problem with readability. It may be obvious that the value is a URL, but which URL?

However, this can be enabled in ORM. Do any ORMs that interact with MongoDb allow you to say that the “u” in db will appear in the “publicationUrl” in the code? When you have things like a.uin code, this is pretty poor readability; article.unot much better.

(There are Ruby and node.js tags because these are the languages ​​that I work with mongo in with. Feel free to add tags.)

+4
source share
3 answers

It is easy with Ruby ORM Mongoid . Here is an example directly from docs :

class Band
  include Mongoid::Document
  field :n, as: :name, type: String
end

band = Band.new(name: "Placebo")
band.attributes #=> { "n" => "Placebo" }

criteria = Band.where(name: "Placebo")
criteria.selector #=> { "n" => "Placebo" }

I used Mongoid in a number of projects (albeit all small ones), and I really like working with it. The docs are really great, and the docs also have a performance section.

+1

Per , Mongoose . , , . , , , , , .

+2

Doctrine MongoDB ODM , , , f.e.:

/** @String (name= "pUrl" ) */ private $publicationUrl;

— MongoDB ODM 1.0.0-BETA2 documentation —

0

All Articles