SimplyBased 0.1.0 — Couchbase-native ActiveModel ORM
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>
This commit is contained in:
commit
86299b8827
84 files changed
+9904
No files matched your search
@@ -0,0 +1,40 @@
|
||||
require 'spec_helper'
|
||||
|
||||
# DRAFT: requires a live CouchDB (like the rest of the suite). These specs
|
||||
# document the intended contract of the bulk-write API.
|
||||
describe "Bulk write API" do
|
||||
describe ".save_all" do
|
||||
it "persists multiple new records in one call and assigns _id/_rev" do
|
||||
result = User.save_all([User.new(title: 'a'), User.new(title: 'b')])
|
||||
result[:saved].size.should eq(2)
|
||||
result[:invalid].should be_empty
|
||||
result[:saved].each do |record|
|
||||
record._id.should_not be_nil
|
||||
record._rev.should_not be_nil
|
||||
record.new?.should be false
|
||||
end
|
||||
end
|
||||
|
||||
it "sets timestamps on new records" do
|
||||
record = User.new(title: 'a')
|
||||
User.save_all([record])
|
||||
record.created_at.should_not be_nil
|
||||
record.updated_at.should_not be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe ".create_all" do
|
||||
it "builds and persists records from attribute hashes" do
|
||||
result = User.create_all([{ title: 'a' }, { title: 'b' }])
|
||||
result[:saved].map(&:title).sort.should eq(['a', 'b'])
|
||||
end
|
||||
end
|
||||
|
||||
describe ".destroy_all" do
|
||||
it "deletes persisted records in one call and clears their ids" do
|
||||
records = User.save_all([User.new(title: 'a'), User.new(title: 'b')])[:saved]
|
||||
User.destroy_all(records)
|
||||
records.each { |r| r._id.should be_nil }
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user