B
B
beduin012019-09-05 14:26:22
MongoDB
beduin01, 2019-09-05 14:26:22

Remove everything that does not match the reference scheme?

Change has a lot of data and several patterns/schemes. I need to compare all entries with the selected templates/schemes and remove all branches that do not match them.
Is this possible in Mongo? If not, are there other tools?
Here is an example document:

{
  "name": "Mike",
  "price": "444",
  "distance": 881,
  "someFiend": 123,
  "lots": [{
      "aa": "111",
      "bb": "222"
    }, {
      "xx": "000"
    }
  ],
  "apps": [{
      "app": 1
    }, {
      "app": 2
    }
  ]
}

Reference pattern with a set of required fields:
{
  "name": "",
  "price": "",
  "lots": [{
      "aa": "",
      "bb": ""
    }, 
  ],
}

I expect the following result:
Expected output:
{
  "name": "Mike",
  "price": "444",
  "lots": [{
      "aa": "111",
      "bb": "222"
    }, 
  ],
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question