Still Being Written Up

Product Class

Create a basic Product class that inherits from a Base model
class Product < ModelBase
  attr_accessor :sku, :name, :price, :description, :related_skus
  
  def initialize (attr = {})  
  end
  
  def quantity
    c = Couchbase.bucket
    doc = c.get("#{@sku.downcase}::quantity")
    return 0 unless doc
    doc
  end 
  
  def in_stock?
    return self.quantity > 0
  end
  
  def create_doc_keys
  
  end
  
  def create_default_docs
  
  end
  
  def create
  
  end
  
  def load_persisted
  
  end
  
end

Products By Category (Small Volume)

  

Products By Category (Larger Volume)

Use a View to create a secondary index based on categories >> products
function(doc, meta) {
  if (doc.type === "product") {
    emit(doc.category, [meta.id, doc.name])
  }
}





Q&A and Comments



 

Q&A and Comments

comments powered by Disqus