package action
Various actions and operations on molecules and entities.
- Source
- package.scala
- Alphabetic
- By Inheritance
- action
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
trait
CompositeInserts extends Helpers
Insert methods to create composite entities containing multiple sub-molecules/tuples.
Insert methods to create composite entities containing multiple sub-molecules/tuples.
Insert composite data
insert( // 2 sub-molecules Article.name.author, Tag.name.weight )( // Rows of tuples, each with 2 sub-tuples of data matching sub-molecules List( (("Battle of Waterloo", "Ben Bridge"), ("serious", 5)), (("Best jokes ever", "John Cleese"), ("fun", 3)) ) )( // Optional transaction meta data molecule saved with the tx entity created MetaData.submitter("Brenda Johnson").usecase("AddReviews") )
Query inserted composite data
We can then query the composite data:
// Important articles submitted by Brenda Johnson // In queries we tie composite sub-molecules together with `~` m(Article.name.author ~ Tag.weight.>=(4).Tx(MetaData.submitter_("Brenda Johnson"))).get === List( (("Battle of Waterloo", "Ben Bridge"), 5) )
Debug a composite insert
Without affecting the database, a composite insert can be debugged with
debugInsertto see the produced output:debugInsert( Article.name.author, Tag.name.weight )( List( (("Battle of Waterloo", "Ben Bridge"), ("serious", 5)), (("Best jokes ever", "John Cleese"), ("fun", 3)) ) )( MetaData.submitter("Brenda Johnson").usecase("AddReviews") ) outputs: ## 1 ## Composite arity-2 insert debug ======================================================================== 1 Model( 1 Atom(article,name,String,1,VarValue,None,List(),List()) 2 Atom(article,author,String,1,VarValue,None,List(),List()) 3 Atom(tag,name,String,1,VarValue,None,List(),List()) 4 Atom(tag,weight,Long,1,VarValue,None,List(),List()) 5 TxMetaData( 1 Atom(metaData,submitter,String,1,Eq(List(Brenda Johnson)),None,List(),List()) 2 Atom(metaData,usecase,String,1,Eq(List(AddReviews)),None,List(),List()))) ------------------------------------------------ 2 List( 1 :db/add 'tempId :article/name 'arg Card(1) 2 :db/add 'e :article/author 'arg Card(1) 3 :db/add 'e :tag/name 'arg Card(1) 4 :db/add 'e :tag/weight 'arg Card(1) 5 :db/add 'tx :metaData/submitter Values(Eq(List(Brenda Johnson)),None) Card(1) 6 :db/add 'tx :metaData/usecase Values(Eq(List(AddReviews)),None) Card(1)) ------------------------------------------------ 3 List( 1 List( 1 :db/add #db/id[:db.part/user -1000097] :article/name Battle of Waterloo Card(1) 2 :db/add #db/id[:db.part/user -1000097] :article/author Ben Bridge Card(1) 3 :db/add #db/id[:db.part/user -1000097] :tag/name serious Card(1) 4 :db/add #db/id[:db.part/user -1000097] :tag/weight 5 Card(1)) 2 List( 1 :db/add #db/id[:db.part/user -1000098] :article/name Best jokes ever Card(1) 2 :db/add #db/id[:db.part/user -1000098] :article/author John Cleese Card(1) 3 :db/add #db/id[:db.part/user -1000098] :tag/name fun Card(1) 4 :db/add #db/id[:db.part/user -1000098] :tag/weight 3 Card(1)) 3 List( 1 :db/add #db/id[:db.part/tx -1000100] :metaData/submitter Brenda Johnson Card(1) 2 :db/add #db/id[:db.part/tx -1000100] :metaData/usecase AddReviews Card(1))) ========================================================================
The two first sections are internal Molecule representations.
The third section shows the transactional data sent to Datomic (except the line indexing numbers in the left column) - in this case two rows of data and one row of transaction data.- See also
Manual: composite inserts | composites
Tests: composite inserts
-
class
Entity extends AnyRef
Entity wrapper with actions on entity.
Entity wrapper with actions on entity.
- See also
Manual | Tests: entity api
-
trait
EntityOps extends AnyRef
Operations on multiple entities.
-
trait
Molecule[Tpl] extends MoleculeBase with CastHelpers[Tpl] with JsonBuilder with GetArray[Tpl] with GetIterable[Tpl] with GetList[Tpl] with GetRaw with GetJson with ShowDebug[Tpl]
Core molecule interface defining actions that can be called on molecules.
Core molecule interface defining actions that can be called on molecules.
Groups of interfaces:
get Get molecule data. getAsOf Get molecule data asOf point in time. getSince Get molecule data since point in time. getWith Get molecule data with given data set. getHistory Get molecule data from history of database. save Save molecule with applied data. insert Insert multiple rows of data matching molecule. update Update molecule with applied data. tx Molecule transaction data (input to `getWith`). debug get Debug calling get method on molecule. debug action Debug calling save/insert/update method on molecule. - Tpl
Type of molecule (tuple of its attribute types)
- See also
Manual: get, time, asOf/since, history, with, getJson, debug/test, save, insert, update, retract
Tests: get, asOf, since, history, with, test asOf, test since, test with, getJson, save, insert, retract,
update, update map, update ref, update multiple attributes, update multiple entities
-
trait
OptionalMapOps extends AnyRef
Container of implicit for optional Map operations.
Container of implicit for optional Map operations.
- See also
-
trait
ShowDebug[Tpl] extends AnyRef
Debug methods
Debug methods
Call a debug method on a molecule to see the internal transformations and produced transaction statements or sample data.

Documentation/API for the Molecule library - a meta DSL for the Datomic database.
Manual | scalamolecule.org | Github | Forum