     (._meta table)))
 
 
-(defn- update-pending
-  "Returns a new `Table` value with the given function applied to update its
-  pending data."
-  [^Table table f & args]
-  (let [patch' (apply f (.pending table) args)]
-    (if (= patch' (.pending table))
-      table
-      (->Table
-        (.store table)
-        (dissoc (.table-info table) ::node/id)
-        (.root-data table)
-        patch'
-        true
-        (._meta table)))))
-
-
-
-;; ## Protocol Implementation
+
+;; ## Internal Functions
 
 (defn- table-lexicoder
   "Construct a lexicoder for the keys in a table."

     table)))


(defn- -delete
  "Internal `delete` implementation."
  [table ids]
  (if (seq ids)
    (let [lexicoder (table-lexicoder table)

                       (::primary-key table))))))))


(defn keys
  "Scan the table, returning keys of the stored records which match the given
  options. Returns a lazy sequence of keys, or nil if the table is empty.

  If min and max keys are given, only records within the bounds will be
  returned (inclusive). A nil min or max implies the beginning or end of
  the data, respectively.

  Options may include:

  - `:min-key`
    Return records with keys equal to or greater than the marker.
  - `:max-key`
    Return records with keys equal to or less than the marker.
  - `:reverse` (NYI)
    Reverse the order the keys are returned in.
  - `:offset`
    Skip this many records in the output.
  - `:limit`
    Return at most this many records."
  ([table]
   (keys table nil))
  ([table opts]
   ; OPTIMIZE: push down key-only read to avoid loading non-base tablets
   (map (comp ::record/id meta)
        (scan table opts))))


(defn read
  "Read a set of records from the database, returning data for each present
  record. Returns a sequence of record data maps.

  Options may include:

  - `:fields`
    Only return data for the selected set of fields. If provided, only
    records with data for one or more of the fields are returned, otherwise
    all fields and records are returned."
  ([table ids]
   (read table ids nil))
  ([^Table table ids opts]
   (if (seq ids)
     (let [lexicoder (table-lexicoder table)
