CFCouchbase SDK
  • Introduction
  • What's New With 2.2.0
  • What's New With 2.0.0
  • About This Book
  • Authors
  • Overview
  • Installation
    • ColdBox Module
    • Traditional Apps
  • Configuration
    • Settings
    • Structure
    • Summary
  • Usage
    • Storing Documents
    • Storage Durability
    • Retrieving Documents
    • Data Serialization
    • Components
      • Auto Inflation
      • Manual Inflation
      • Custom Serialization
      • Binary
    • Custom Transformers
    • Executing Queries
      • View Queries
      • n1ql Queries
      • Query Options
      • Filter Closures
      • Transform Closures
      • Return Types
    • Managing Views
    • Working With Futures
  • Help & Support
Powered by GitBook
On this page
  • Song.cfc
  • Usage
  • CFC data in couchbase

Was this helpful?

Edit on GitHub
Export as PDF
  1. Usage
  2. Components

Auto Inflation

You can annotate a CFC with autoInflate and CFCouchbase will be smart enough to detect the CFC's path and defined properties so it can store them in Couchbase. When storing the component, the data will be stored as a JSON struct along with some metadata about the component. When retrieving that document from Couchbase, a new component will be created with the inflated data. This is the easiest approach as it is completely seamless and pretty fast I might say!

Song.cfc

component accessors="true" autoInflate="true"{
    property name="title"  default="";
    property name="artist" default="";
}

Usage

funkyChicken = new path.to.song();
funkyChicken.setTitle( "Chicken Dance" );
funkyChicken.setArtist( "Werner Thomas" );

// Pass the CFC in
couchbase.upsert( 'funkyChicken', funkyChicken );

// And get a CFC out!
birdieSong = couchbase.get( 'funkyChicken' );

writeOutput( birdieSong.gettitle() );
writeOutput( birdieSong.getArtist() );

CFC data in couchbase

{
  "data": {
    "title": "Chicken Dance",
    "artist": "Majano",
  },
  "classpath": "model.funky.Song",
  "type": "cfcouchbase-cfcdata"
}

As you can see, this approach will allow you to still create views about your data in Couchbase if necessary and also provide a nice way to do CFC to Couchbase to CFC translations.

PreviousComponentsNextManual Inflation

Last updated 7 years ago

Was this helpful?