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 8342541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:48:21+00:00 2026-06-09T05:48:21+00:00

I know how to update a document in CouchDB, but when I update a

  • 0

I know how to update a document in CouchDB, but when I update a doc, the fields that I didn’t specify for the update gets deleted. How do I restrict the same. For instance, my CouchDB doc consists of fields: Name,Age,Email and I would like to update only the email field of this doc. So I just pass in the email field, it,s value, the doc id and its corresponding rev. But when I do such an update, my doc now will consist of only the E-mail. How do I restrict this., i.e, only the email id gets updated keeping the remaining fields and it’s value intact.
I am using jquery.couch.js

  • 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-09T05:48:22+00:00Added an answer on June 9, 2026 at 5:48 am

    Perhaps you are doing it all wrong… you are trying to solve the problem in CouchDB in non-CouchDB way. Why are you storing all the comments in one document? If you want to retrieve them in one request with the post, then you can use map to aggregate post and comments from separate documents like this:

    Post document: { _id: "post1", type: "post", ... }
    Comment document:

    { type: "comment",
      post: "post1", // id of the post being commenting
      ...
    }
    

    Map:

    function (self) {
      if (!self.type) return;
      if (self.type == "post") {
        emit([self._id, 0], self);
      } else if (self.type == "comment" && self.post) {
        emit([self.post, 1, self.time], self);
      }
    }
    

    Retrieve post with comments with sorted by date:

    curl http://127.0.0.1:5984/yourdb/_design/yourapp/_view/yourview?startkey=[%22post1%22]&endkey=[%22post1%22,{}]
    

    In this way you can also retrieve only some of the comments and implement paging easily. All the comments should will be store in B-tree close to the post, so it should also be efficient.

    Same approach is described in details here.

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

Sidebar

Related Questions

I'm trying to update a hash that's nested in a MongDB document. I know
I want to know Id update panel that initial a request in JavaScript .I
UPDATE: I know I can use <ol> directky in the output but I remember
I know that in standard SQL you can do this: update top (100) table1
How can I update an embedded document that is more than one level deep
Knowing that my document.activeElement is an input field (I don't know exactly the name
I have an Excel document (2007) with a chart (Clustered Column) that gets its
I want update an _id field of one document. I know it's not really
I need to insert a document if it doesn't exist. I know that the
I know that SHA256_Update() is implemented in libcrypto under openssl, yet, a simple grep

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.