Created
July 19, 2019 13:12
-
-
Save shipcake/c5e2221a25c9032f04c2931435aa0fcc to your computer and use it in GitHub Desktop.
how to pull all object in array by data._id condition?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//find property_type in products to delete them. | |
const findallid = await products.findOne({ "storeuid": ctx.token.storeuid}).lean() | |
const MapId = await R.map(findallid.data,i=>{ | |
return i._id | |
}) | |
console.log(MapId) <--- return like [id1,id2...] | |
const remove = await products.findOneAndUpdate( | |
{ "storeuid": ctx.token.storeuid }, | |
{ | |
$pull:{"data.$[dataid].property_type":{subtypeid:iddel}} | |
}, | |
{ | |
arrayFilters:[{[`dataid._id`]:{$each:MapId}}] | |
} | |
) | |
return {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment