I would like to extract a list of ean from my MongoDB database. With "find ()" I get separate documents. I would like to get a list of ean in a unique view of the document, or at most in an array. I know that I could read the data in php and process them. But since I'm learning to use MongoDB and "MongoDB Driver" for PHP I would like to understand how to extract data directly from the database using commands.
My DB:
{
"_id" : "ID0001",
"ean" : [
"4960999612638",
"4960999150437",
"0050332160514"
]
}
{
"_id" : "ID0002",
"ean" : [
"4960999213743"
]
}
{
"_id" : "ID0003",
"ean" : [
"0050332143265",
"0050332143258"
]
}
{
"_id" : "ID0004",
"ean" : [
"0050332160514"
]
}
What I would like to get (or similar):
{
"ean" : [
"4960999612638"
"4960999150437"
"0050332160514"
"4960999213743"
"0050332143265"
"0050332143258"
]
}
I would also delete duplicate ean by the results, but that's another story...
I can do this with mongodb?
Thanks to all those want help me!