Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search by reference Document. #83

Open
devdebonair opened this issue Aug 8, 2016 · 2 comments
Open

Search by reference Document. #83

devdebonair opened this issue Aug 8, 2016 · 2 comments

Comments

@devdebonair
Copy link

class Ticket extends Document {
    constructor() {
        super();

        this.user = User;
        this.event = Event;
    }

    static collectionName() {
        return "tickets";
    }
}

Ticket.find({event: "random ObjectID"})

No matter what this always comes back as an empty array and I am sure the document is in the database. When I pass the find function an ObjectID(), I get an error stating that the argument must be a string. I am able to find it in the console through this command.

db.tickets.find({ "_id": ObjectId("random ObjectID") })

Any ideas why this may be happening?

@ghost
Copy link

ghost commented Feb 21, 2017

I have the same problem here. Is this implemented or is not supported?

@ghost
Copy link

ghost commented Feb 22, 2017

@devdebonair
I found something that may help.
Passing an new ObjectID('random ObjectID') to find does work, but using the latest mongodb package is incompatible, switching to the same version camo is using (2.0.42) works.

import { ObjectID } from 'mongodb';

DB.then(() => {
  Character
    .find({
      owner: new ObjectID('some random ID')
    })
    .then(res => res.map(u => u.toJSON()))
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant