rodrigolive/mongoose — Issue #16: Mongoose saves Documents Relations with '$' that makes find() impossible
Author: kthakore
Created: 2011-12-28 00:35:48+00:00
State: open

```
package Bar;
use Moose;
with 'Mongoose::Document';
has 'stuff' => (is => 'rw', isa => 'Str', required => 1 );
1;

package Foo;
use Moose;
with 'Mongoose::Document';
has 'other_stuff' => (is => 'rw', isa => 'Str' );
has 'bars' => (is => 'rw', isa => 'Bar' );
1;
```

This is saved as:

```
{ "bar" : { '$ref' : '...', '$id': '4e9ac....' ....

```
The problem with this is I can't do:

``` db.foo_bar.find( { "bar" : { "$ref" : { "$oid" : "4e9ac ... ```

That is JSON error as '$' is an operation in the query syntax for MongoDB for example '$ne' ...

This is a big problem because it prevents find from working and we have to do a foreach and do a search in Perl which is slower. Can we not use '_' instead there?