Nic Oosthuizen
Nic Oosthuizen

Reputation: 1

MondoDB $locate

I have two collections, a policy collection, and a person collection The Policy looks something like this:

[{
    "_id": {
        "$oid": "61169375e2145bbfd73dedbe"
    },
    
    "PolicyNumber": {
        "Identifier": "A56B096A",
        "Sequence": 1
    },
    
    "Persons": {
        "61169362982ac4e8ae2ad768": null,
        "60de07a8dc031e91ac5f35c0": null
    },
}]

The Person:

[{
  "_id": {
    "$oid": "5f0c6d087937e0000145e5c3"
  },
  "UniqueCode": "PER0004",

  "PassportExpiryDate": null,
  "Age": 35,
  "Gender": "M",
  "Nationality": null,
  "LanguageCode": null,
  "Name": "NAME",
  "Surname": "SURNAME",
  "Initials": null,
  "ContactDetails": {
    "Addresses": {
      "physicalAddress": {
        "AddressType": null,
        "UnitNumber": null,
        "UnitName": null,
        "PoBox": null,
        "StreetNumber": null,
        "StreetName": null,
        "Suburb": null,
        "Town": null,
        "PostalCode": "7100",
        "Country": null,
        "Coordinates": null,
        "InitialCenter": null
      }
    },
    "EmailAddresses": {
      "emailAddress": "[email protected]"
    },
    "TelephoneNumbers": {
      "cellphone": "0000000000"
    },
    "PreferredCommunicationMethod": "SMS"
  },
  "BankingDetails": [],
  "Statistics": null,
  "Imported": false,
  "ImportReference": null
}]

I have tried various options with $locate, $let, $convert, etc to enable me to join the two collections on 'Persons' using the Policy collections as the entry point.

I know this is probably fundamentals, but I'm n SQL guy who got dumped with a MongoDB conversion.

Any assistance will be appreciated

Upvotes: 0

Views: 25

Answers (0)

Related Questions