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

  • Home
  • SEARCH
  • 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 8023437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:33:45+00:00 2026-06-04T22:33:45+00:00

Given the following object structure: { key1: …, key2: …, data: … } Is

  • 0

Given the following object structure:

{
   key1: "...",
   key2: "...",
   data: "..."
}

Is there any way to get this object from a CouchDB by quering both key1 and key2 without setting up two different views (one for each key) like:

select * from ... where key1=123 or key2=123

Kind regards,
Artjom

edit:

Here is a better description of the problem:
The object described above is a serialized game state. A game has exactly one creator user (key1) and his opponent (key2). For a given user I would like to get all games where he is involved (both as creator and opponent).

  • 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-06-04T22:33:46+00:00Added an answer on June 4, 2026 at 10:33 pm

    Emit both keys (or only one if equal):

    function(doc) {
      if (doc.hasOwnProperty('key1')) {
        emit(doc.key1, 1);
      }
      if (doc.hasOwnProperty('key2') && doc.key1 !== doc.key2) {
        emit(doc.key2, 1);
      }
    }
    

    Query with (properly url-encoded):

    ?include_docs=true&key=123
    

    or with multiple values:

    ?include_docs=true&keys=[123,567,...]
    

    UPDATE: updated to query multiple values with a single query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given this XML structure from (http://localhost:3000/route.xml): <objects type=array> <object> <trip0> <departure>20:01</departure> <start>Place a</start> <end>Place
Given the following object: public class Product { string Name {get;} int Quantity {get;}
Given the following structure... class Foo { public string Category { get; set; }
Given the following data structure var things = [{ name: thing1, sex: male}, {
Given the following JavaScript data structure - how would you describe it? BLA =
I want to find out the following: given a date ( datetime object), what
I found the following statement: Map is an object that stores key/volume pairs. Given
// given following array: $data = array( 0=>array( data=>object1, col=>array( 0=>array( data=>object2, col=>array( 0=>array(
Given the following class structure: class Base { virtual void outputMessage() { cout <<
Is there a more appropriate/efficient data structure for a transaction queue than using a

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.