couchface

a couchbase sdk wrapper

Usage no npm install needed!

<script type="module">
  import couchface from 'https://cdn.skypack.dev/couchface';
</script>

README

Couchface

PrisonMike

Couchbase Base ODM to be. Uses SDK 3.x.x asd


Ok some concepts..

Couchbase is a cluster

A Cluster has buckets

a Bucket has 1-n scopes \ collections

Couchbase is a key value -> Every document has a key. The fastest lookups are key lookups aka refdec indices -> Primary index

By default Couchface will fire a create primary index query By default all the create primary index queries on boot up will be differed so that couchbase can index everything together. Other indices predefined in the models will be differed. It's not a feature yet. Once it is I'll update here.

Is this an ORM or an ODM? Well thanks to Couchbase's lack of decision on approach it's a bit of both.

A N1Ql Operation:

  • Generic CRUD operation that returns a row format
  • Defined relations will yield joins
  • Hydrate a row into an actual object through (type and model registry lookup)

A Document Look up:

  • Document queries thanks to lenient index API.
  • Collection & Scope document lookup
@Index('a', {})
@Document('bucko')
class Doc1 extends CfDocument {
  public static DocType() {
    return 'Doc1';
  }

  @Validate(( val ) => {
    if (val > 1) {
      return true;
    }
    throw new Error('value is not larger than 1');
  })
  @Property()
  p1 = 12;
}

@SubDocument(Doc1, 'I.am.path')
class SubDoc1 extends CfSubDocument {

}

SubDoc1.get('OneDocumentKey_value'); // -> The id is still the actual document's
// but this is using the sub document API! -> We never pull the entire document
// this will pull only that portion.