Skip to content

We need some better documentation please #119

@elfeffe

Description

@elfeffe

This is not a bug in the code (I hope) but is a problem with the documentation.
I find how to get collections and then do a var_dump, but I can't find any place that helps me to get some field on that object.
I have tried every single way to do this, and it seems that find or findOne doesn't work. Documentation is not good enough and that's very bad for MongoDB, we just can't advance in our projects.

I have this document

{ 
    "_id" : ObjectId("56a22142bd1457041e2c94b2"), 
    "anonymousId" : "7f668198-e985-426e-9232-084c440f7293", 
    "channel" : "client", 
    "context" : {
        "ip" : "1.175.1.14", 
        "library" : {
            "name" : "analytics.js", 
            "version" : "2.11.1"
        }, 
        "page" : {
            "path" : "/", 
            "referrer" : "http://www.google.com/", 
            "search" : "", 
            "title" : "Title", 
            "url" : "http://www.google.com"
        }, 
        "userAgent" : "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0"
    }, 
    "integrations" : {

    }, 
    "messageId" : "ajs-492650bab68cd4305f8a56a769299ea6", 
    "originalTimestamp" : "2016-01-22T12:32:10.657Z", 
    "projectId" : "V7vqDI8qKo", 
    "receivedAt" : "2016-01-22T12:32:01.832Z", 
    "sentAt" : "2016-01-22T12:32:10.657Z", 
    "timestamp" : "2016-01-22T12:32:01.832Z", 
    "type" : "identify", 
    "userId" : "user@gmail.com", 
    "version" : NumberInt(2)
}

Can somebody tell me how to get userId from that document in PHP?
Also I have noticed that find and findOne returns different objects, different data.
Can somebody tell me how to get userId from one result and from a collection in a foreach?

This is a silly question, but I can't find any documentation that says that. All the examples are for the old driver (mongo, not mongodb), but not for this.
Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions