Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6783045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:49:04+00:00 2026-05-26T16:49:04+00:00

Given a collection of items { url: ‘http://blah’ }. How can I tell if

  • 0

Given a collection of items { url: ‘http://blah’ }. How can I tell if a record exists where the url is “http://stackoverflow.com”?

P.s. I am communicating with the c# driver

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:49:04+00:00Added an answer on May 26, 2026 at 4:49 pm

    For any of the previous suggestions to be efficient you should be sure that there is an index on the url element. Otherwise a full collection scan will be required.

    If you only expect the answer to be 0 or 1, count is probably the most efficient approach. If you think the count will be very large and all you really care about is whether there is one or more, FindOne is the most efficient approach.

    It probably doesn’t matter that FindOne returns the whole document unless the document is actually rather large. In that case you could tell the server to only return one field (the _id seems the most likely candidate):

    var query = Query.EQ("url", "http://stackoverflow.com");
    var fields = Fields.Include("_id");
    var res = collection.Find(query).SetFields(fields).SetLimit(1).FirstOrDefault();
    if (res == null) {
        // no match found
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given: <TextBox Text='{Binding MyCollection[MyIndex].MyProperty}'/> where: MyCollection is an observable collection of MyClass items MyClass
Given: Several million records in a mongo collection. Each record has 10 fields, of
Given a linq expression of an object collection 'items' such as this: var total
Given a collection of items, how do I split the collection into 2 sub-collections
I am given a class Shop that maintains a collection of items of type
im getting a CFDictionaryAddValue(): immutable collection 0xd5aea0 given to mutating function error when i
Given a .net 4. collection, if I want to pass in my own custom
Given the following XML structure: <root> <data>x</data> <details> <some_other_element>...</some_other_element> <collection> <element><a>1</a></element> <element><a>2</a></element> <element><a>3</a></element> <collection>
I can see that Collections.unmodifiableSet returns an unmodifiable view of the given set but
Given a collection of integers, what's a Java algorithm that will give all pairs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.