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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:26:03+00:00 2026-05-20T18:26:03+00:00

I have a CouchDB view from which I emit three or four fields. If

  • 0

I have a CouchDB view from which I emit three or four fields.

If the PHONE_MOBILE field is empty for a given record, the view output contains null

Instead I’d like it to emit “” (i.e. blank string/nothing)

What’s the best way to achieve this? Here’s the view code:

{
   "_id": "_design/blah",
   "_rev": "20-e07e50de179d0df5e7bce52fdb7ee4d2",
   "views": {
       "by_surname3": {
           "map": "function(doc) { if (doc.SURNAME)  emit(doc.SURNAME.toLowerCase(), {SURNAME: doc.SURNAME, FIRSTNAME: doc.FIRSTNAME, PHONE_MOBILE: doc.PHONE_MOBILE}) }"
       }
   }
}

Thanks

  • 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-20T18:26:03+00:00Added an answer on May 20, 2026 at 6:26 pm

    You can use something like this:

    function(doc) { 
      if (doc.SURNAME)  
        emit(doc.SURNAME.toLowerCase(), {
            SURNAME: doc.SURNAME, 
            FIRSTNAME: doc.FIRSTNAME, 
            PHONE_MOBILE: (doc.PHONE_MOBILE ? doc.PHONE_MOBILE : "")
        }) 
    }
    

    Or, if you prefer, the or operator to provide a default.

    function(doc) { 
      if (doc.SURNAME)  
        emit(doc.SURNAME.toLowerCase(), {
            SURNAME: doc.SURNAME, 
            FIRSTNAME: doc.FIRSTNAME, 
            PHONE_MOBILE: (doc.PHONE_MOBILE || "")
        }) 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a chat CouchDB which stores records with following format. type:chat, email:p@g.com, friendEmail:m@g.com,
Given that I have some number of documents in my CouchDB database, I would
I have a normal Rails project (without Active Record) using CouchDB (couchrest_model) as a
I have a Sproutcore application which uses CouchDB hosted by Cloudant. In devenv I'm
I have errors when updating document in Couchdb 1.1.0 after updating it from 1.0.1
I have a CouchDB server that is running behind a front end proxy which
If I have a CouchDB document with a handful of metadata fields and a
i have a database in couchdb which contain 4 documents... here the sample and
I have a bunch of MP3 metadata in CouchDB. I want to return every
CouchDB, version 0.10.0, using native erlang views. I have a simple document of the

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.