Questions tagged [odm]

Object Document Mapper Is a programming technique for converting data between incompatible type systems in object-oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language. There are both free and commercial packages available that perform object-relational mapping, although some programmers opt to create their own ODM tools.

218 questions
200
votes
10 answers

MongoDB/Mongoose querying at a specific date?

Is it possible to query for a specific date ? I found in the mongo Cookbook that we can do it for a range Querying for a Date Range Like that : db.posts.find({"created_on": {"$gte": start, "$lt": end}}) But is it possible for a specific date ? This…
Unitech
  • 5,781
  • 5
  • 40
  • 47
193
votes
6 answers

What is the difference between an ORM and an ODM?

I am trying to figure out what the difference is between ORM and ODM, as far as I understand the concept, ORM (Object Relational Mapper) maps the relations between data, where as ODM (Object Document Mapper) deals with documents. Am I right in…
Odyss3us
  • 6,457
  • 18
  • 74
  • 112
83
votes
14 answers

Mongoid or MongoMapper?

I have tried MongoMapper and it is feature complete (offering almost all AR functionality) but i was not very happy with the performance when using large datasets. Has anyone compared with Mongoid? Any performance gains ?
PanosJee
  • 3,866
  • 6
  • 36
  • 49
38
votes
8 answers

convert javascript plain object into model class instance

I need to implement small ODM like feature. I get plain javascript object from database, and I need to convert it into my model class instance. Let's assume model looks like: class Model{ constructor(){ this.a = '777'; …
silent_coder
  • 6,222
  • 14
  • 47
  • 91
27
votes
3 answers

Querying array elements with Mongo

How can I query the smoothies that have apple in them? (below is a collection with 3 documents) _id => 1 name => 'best smoothie' ingredients => Array ( [0] => apple [1] => raspberry [2] => orange [3] => banana …
Devrim
  • 2,826
  • 5
  • 25
  • 31
23
votes
3 answers

Mongoose ODM, change variables before saving

I want to create a model layer with Mongoose for my user documents, which does: validation (unique, length) canonicalisation (username and email are converted to lowercase to check uniqueness) salt generation password hashing (logging) All of…
dev.pus
  • 7,919
  • 13
  • 37
  • 51
17
votes
3 answers

Mongoose.model vs Connection.model vs Model.model

I am bit confused with usage of models in mongoosejs Models can be created using mongoose in these ways Using Mongoose var mongoose = require('mongoose'); var Actor = mongoose.model('Actor', new Schema({ name: String })); Using Connection var…
Prashant Bhate
  • 10,907
  • 7
  • 47
  • 82
16
votes
2 answers

Nodejs Object Document Model for Redis

I'm want use an ODM for redis in node.js. Does anybody have any experience using any? I ideally want something that is somewhat the equivalent of mongoose (except instead for Redis instead of Mongodb). The two I have heard of so far are nohm and…
GTDev
  • 5,488
  • 9
  • 49
  • 84
11
votes
2 answers

Doctrine MongoDB ODM search in two or more fields

I would like to write a query in Doctrine Mongo ODM that searches by regex in two or more fields. In SQL it would look like: SELECT * FROM user WHERE name LIKE %search% OR surname LIKE %search%; I can write a query for one field like…
bazo
  • 745
  • 9
  • 26
11
votes
1 answer

Is it possible to use sort() on multiple fields in Doctrine 2 ODM?

I am doing a query on a result document in my doctrine mongodb *odm*. There are two indexed fields in the document which I would like to use in sort. I have written something like: $results = $this->createQueryBuilder('Document\Score') …
Himel Nag Rana
  • 744
  • 1
  • 11
  • 19
10
votes
3 answers

php70-mongo install doctrine/mongodb-odm fails

I try to install doctrine/mongodb-odm[1.0.5] over composer but drops me Problem 1 - doctrine/mongodb 1.3.0 requires ext-mongo ^1.5 -> the requested PHP extension mongo is missing from your system. - doctrine/mongodb 1.2.2 requires…
deroccha
  • 1,181
  • 4
  • 22
  • 41
10
votes
2 answers

MongoDB - Query conundrum - Document refs or subdocument

I've run into a bit of an issue with some data that I'm storing in my MongoDB (Note: I'm using mongoose as an ODM). I have two schemas: mongoose.model('Buyer',{ credit: Number, }) and mongoose.model('Item',{ bid: Number, location: { type:…
jordan
  • 9,570
  • 9
  • 43
  • 78
8
votes
1 answer

Creating a model in nodejs without an ORM or ODM

I am surprised why this is so hard to find. I am trying to convert my monolith to a 3 layer architecture for my node express app with a propriety sql. Repository BEFORE architecture change 1 file entry.js 1 endpoint with business logic Functions…
codesim
  • 111
  • 7
7
votes
1 answer

Doctrine MongoDB use without ODM

I am using Doctrine MongoDB within Symfony2, but now I want to do some things which for me are easier without the ODM, how can I get the MongoClient or MongoCollection object? I want to use MongoDB in the old-fashioned way…
joschua011
  • 4,157
  • 4
  • 20
  • 25
6
votes
2 answers

How to use Mongoose in Meteor?

I've looked at the answer posted here: Meteor: integration with Mongoose?, but I'm looking for a simpler, more modular solution if possible for using Mongoose with Meteor.js. Is there a better way that I should be handling ODM or native support I…
ilmatic
  • 565
  • 3
  • 11
1
2 3
14 15