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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:43:01+00:00 2026-05-26T03:43:01+00:00

I use Couch DB with Ektorp at Spring 3. I read the document and

  • 0

I use Couch DB with Ektorp at Spring 3. I read the document and have tried to implement examples. I am so new to these technologies. This is the point where I didn’t understand:

@View( name = "all", map = "function(doc) { if (doc.type == 'Sofa' ) emit( null, doc._id )}")
public class SofaRepository extends CouchDbRepositorySupport<Sofa> {

    @View( name = "avg_sofa_size", map = "function(doc) {...}", reduce = "function(doc) {...}")
    public int getAverageSofaSize() {
        ViewResult r = db.queryView(createQuery("avg_sofa_size"));
        return r.getRows().get(0).getValueAsInt();
    }

}

How does that wievs work and how to define them, what happens at that lines?

  • 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-26T03:43:02+00:00Added an answer on May 26, 2026 at 3:43 am

    CouchDbRepositorySupport out of the box provides the following methods to the SofaRepository:

    public void add(Sofa entity);
    public void update(Sofa entity);
    public void remove(Sofa entity);
    public Sofa get(String id);
    public Sofa get(String id, String rev);
    public List<T> getAll();
    public boolean contains(String docId);
    

    By having this inline view annotation for CouchDbRepositorySupport:

    @View( name = "all", map = "function(doc) { if (doc.type == 'Sofa' ) emit( null, doc._id )}") 
    

    You redefine the return from a getAll() method.

    You also adding another method getAverageSofaSize() to your repository, with inline View:

    @View( name = "avg_sofa_size", map = "function(doc) {...}", reduce = "function(doc) {...}")
    

    which explicitly provides a query that db.queryView(createQuery("avg_sofa_size")); undersntad. db here is a CouchDbConnector that is able to create, delete, purge, find, etc..

    Take a look at more documentation about defining in line Views

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

Sidebar

Related Questions

I am examining example Blog example of CouchDB. I use Ektorp at Spring for
use this website a lot but first time posting. My program creates a number
I have a simple database with couch db. I have users have that fields:
use javascript or other method ? have any recommendation?
Use Eclipse Classic with ADT plugin. Tried to make project from existing example of
Use case: You have 2-3 files displayed in your MacVim window(s). You press ctrl+Q
We have got a setup where users can either use a web-based form or
Couch has a REST interface. This means that data-updates are exclusive to PUT calls.
I have a web app served by cherrypy. Within this app, I would like
I have a number of documents which look like this: {userId: 123, msg:{ timestamp:123456,

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.