Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Couchbase | Couchbase Server 2.0

doc type and indexing

3 replies [Last post]
  • Login or register to post comments
Wed, 02/06/2013 - 07:37
rkb
Offline
Joined: 11/06/2012
Groups: None

In an example that I saw in creating an index/view I see:

function(doc, meta) {
if(doc.type == "brewery" && doc.city) {
emit(doc.city, null);
}
}

My question is what determines the doc.type? I would be writing a document like:

client.Store(StoreMode.Add, destination.SKU, destination);

Which argument on the store determines the doc.type?

Top
  • Login or register to post comments
Thu, 02/07/2013 - 02:02
tgrall
Offline
Joined: 09/05/2012
Groups: None

Hello,

The short answer is : "You as a developer determine the doc type".

Couchbase allows you to store "anything" up to 20Mb, when you store JSON document they will be indexed by the views.

But the document are not "typed" by the server, so when you want to execute specific treatments, as you describe in the view above you have to type the document yourself.
This is usually done with a json attribute called "type", but you can use any type you want.

I am inviting your to look at this chapter about document modeling in the "Couchbase Developer Guide"
- http://www.couchbase.com/docs/couchbase-devguide-2.0/modeling-documents....
and especially :
- http://www.couchbase.com/docs/couchbase-devguide-2.0/working-with-out-sc...

HTH

__________________

Tug
@tgrall

Top
  • Login or register to post comments
Thu, 02/07/2013 - 06:17
rkb
Offline
Joined: 11/06/2012
Groups: None

Thank you. These two links are invalid. They cannot be resolved.

Top
  • Login or register to post comments
Thu, 02/07/2013 - 09:22
tgrall
Offline
Joined: 09/05/2012
Groups: None

Strange they do work for me let me put shorter version of it:
- http://goo.gl/pIrWR
- http://goo.gl/h3oGV

__________________

Tug
@tgrall

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker