My concern is ram consuming on mongodb.
Does mongodb consume same ram at this two situation?
I believe the two queries you posted are very similar in nature, and thus would have negligible difference in actual RAM usage between them.
MongoDB uses RAM mainly to contain your working set, incoming connections, in-memory sorts, and others. MongoDB would always try to use as much RAM as possible to ensure that the server can be as performant as possible.
However, I’m not sure if I fully understand your question. Are you concerned that your operations using excessive RAM? Or is there a background story to the question? If overall RAM usage is your concern, you might want to take a look at How do I calculate how much RAM I need for my application