A from-scratch fork of simply_couch's model layer that runs on Couchbase natively: `include SimplyBased::Model` instead of `include SimplyCouch::Model`. - SimplyBased::Store replaces the CouchDB layer: KV documents, N1QL/SQL++ finders + lazily-created GSIs, CAS mapped onto _rev. No design documents or JavaScript map/reduce — the hand-written association views become N1QL (belongs_to/has_many/has_one scalar FK; habtm via ANY ... SATISFIES + array index, or KV multi-get on the storing side). - Redis replacements on the same cluster: Counter (atomic increment/decrement), Cache (ActiveSupport::Cache::Store over KV+TTL, drop-in Rails.cache/ActiveJob), Lock (insert-if-absent + TTL + CAS-checked release). - Runs the simply_couch test suite against live Couchbase: 378/432 applicable examples green (CouchDB-mechanic specs tagged :couchdb_only and excluded). - Remaining: ancestry (tree) + embedded_in reverse-lookups (recursive/embedded N1QL) and a few pagination/lifecycle edges. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
42 lines
1.5 KiB
Ruby
42 lines
1.5 KiB
Ruby
# Please move me to a proper location
|
|
class String
|
|
def property_name
|
|
underscore.gsub('/','__').gsub('::','__')
|
|
end
|
|
end
|
|
|
|
# Guard on a sentinel that only this file defines (SimplyBased::VERSION), not on
|
|
# the bare SimplyBased constant. A plugin gem (e.g. simply_couch-couchbase) may
|
|
# open `module SimplyBased` for its own version/namespace before this file loads;
|
|
# guarding on the bare module would then skip the library's whole initialization.
|
|
unless defined?(SimplyBased::VERSION)
|
|
$:<<(File.expand_path(File.dirname(__FILE__) + "/lib"))
|
|
require 'simply_based/instance_methods'
|
|
require 'simply_based/class_methods_base'
|
|
|
|
module SimplyBased
|
|
VERSION = '0.1.0'
|
|
class Error < RuntimeError; end
|
|
class RecordNotFound < RuntimeError; end
|
|
class NotImplementedError < RuntimeError; end
|
|
class ModelNotInstantiatedError < RuntimeError; end
|
|
class NotFound < RuntimeError; end
|
|
|
|
# No-op retained for source compatibility with SimplyCouch. SimplyBased
|
|
# never interpolates values into JavaScript views — queries are N1QL with
|
|
# bound parameters — so there is nothing to sanitize. Returns its tokens.
|
|
def self.assert_safe_view_token!(*tokens)
|
|
tokens
|
|
end
|
|
end
|
|
|
|
require 'simply_based/document_codec'
|
|
require 'simply_based/database_config'
|
|
require 'simply_based/model'
|
|
require 'simply_based/store'
|
|
require 'simply_based/redis'
|
|
require 'core_ext/time'
|
|
require 'core_ext/date'
|
|
end
|
|
class SimplyBased::Conflict < StandardError; end
|