I have the following data in MongoDB:

  "_id":BinData(3, "Q6z94uPrW0+IcUnjkwjFCw=="),
  "FormID":BinData(3, "nMVvjlcHGU68zFBBCeYdsg=="),
  "ContactId":BinData(3, "YJYiH5EJO0SPltvqhMrouw=="),
  "InteractionId":BinData(3, "ZQ1y+QcNf0qFzVvF6Axu+Q=="),
  "Timestamp":  ISODate("2016-10-25T11:42:57.406  Z"),
      "FieldId":BinData(3, "SFmIPHlDp0y8t3KueJPHDQ=="),
      "FieldName":"Tell us a bit about yourself"
      "FieldId":BinData(3, "SwTNPjQv80GYm0/Y0ZO/Tg=="),
      "FieldId":BinData(3, "a3P3HWsSj0SPXepMcqb5Fw=="),
      "Value":"[email protected]"
      "FieldId":BinData(3, "TeZGzCvk0Um6Pia1gtZXFQ=="),
      "FieldName":"Company Name",
      "FieldId":BinData(3, "GdX6eYcN2ka5Crjn2eex/A=="),
      "Value":"dont test the tester."

How can we get this data based on a specific value?

  • 2
    Could you explain what you mean about "data based on a specific value"? Is this WFFM data? It would help those who can answer if you can say what this data is and what you're trying to get out of it.
    – Kasaku
    Oct 27, 2016 at 10:53
  • Is this a Sitecore question or a mongo one, loosely based on Sitecore simply because it is WFFM data?
    – jammykam
    Oct 27, 2016 at 10:57
  • I thought the same @jammykam, but I think worth asking because if it is WFFM then there could be an API already for trying to get the data they're after?
    – Kasaku
    Oct 27, 2016 at 11:00
  • yes.its the WFFM data.suppose I have value as tester in filedname:Name.so based on tester key word how can I get the data of that particular contact Id?
    – Indrasena
    Oct 27, 2016 at 11:05
  • 2
    @Kasaku I agree with you, but as it stands, this is a Mongo question (and vague at that) so the OP needs to rewrite the question with more details.
    – jammykam
    Oct 27, 2016 at 12:28

1 Answer 1


A word on UUIDs

The "3" part of the BinData field indicates that this is a Legacy UUID. If you are using a tool like MongoChef you can alter this representation to a .NET-encoded GUID using the Legacy UUID tab in the Preferences dialog, launched from the Edit menu. Select the entry Legacy .NET/C# Encoding.

This should present the value in the form: AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE (.NET UUID) which will be easier to digest, visually speaking. The values are equivalent and MongoDB as everything is stored in binary in the end anyway. This is just about how the value is drawn to the screen in the client application.

You need to execute the query using the BinData(3, "") notation with a first param of 3 if the field originally contained a .NET Guid. The value you mentioned for _id is actually 43acfde2-e3eb-5b4f-8871-49e39308c50b (it's just Base64 encoded). I can't guarantee that byte order is per the .NET encoding as I got it from the FileFormat.info site.

Query Syntax

While that's all interesting, I think you're asking about actually querying MongoDB. This isn't really the place for such a question, but you query it using JSON as follows:

Search for a record by ID:

Query: { "_id": BinData(3, "Q6z94uPrW0+IcUnjkwjFCw==") }

Search for a record containing the value 'tester':

Query: { "Fields.Value": "tester" }

Search for a record where the field 'Name' has the value 'tester':

Query: { Fields: { $elemMatch: { "FieldName": "Name", "Value": "tester" } } }

In this example the $elemMatch operator is used to locate any element in the array that matches the provided criteria. Some incorrect versions of this you might have tried:

{ "Fields.FieldName": "Name", "Fields.Value": "tester" }

While similar, this will locate any object containing an element in the Fields array with the FieldName = "Name", and, with an element in the Fields array with the Value = "tester" - not necessarily in the same child object! You don't want that as you'll get false positives.

{ "Fields": { FieldName: "Name", Value: "tester" } }

This version will search for an object where the Fields array contains a sub-document that looks exactly like the one in the query, that is, no additional fields; just FieldName and Value. You don't want that as the sub-document also contains the FieldId attribute (though you could probably locate this value in Sitecore if you already know the field name to search).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.