Assets, Entities and Inventories Pub

Support for entities and inventories

The diesel domain modelling has built-in support for entities. Entities (and assets) have a JSON representation and have a class and a key and are persisted and managed by an inventory or domain plugin. These inventories can be defined in a few ways:

  • built in diesel inventories
  • rules based - the most common, where you define a set of rules
  • code based - some inventories require specific code and are embedded in the server (when hosted in your docker)

You can define classes part of Domain Modelling and bind them to inventories. After that, you can simply use these as entities in flows with CRUD messages, browse them with the built-in diesel browsers etc

Client messages when using the entity support:

  • diesel.inv.register use this to register a new inventory to manage some classes
  • diesel.inv.connect create a new connection for an inventory. If you don't need to manage multiple connections per inventory, leave empty "" or use "default" as the connection name.

Entity CRUD:

Example (see more in diesel-inv-story):

$send diesel.inv.create (class="TestClass1", entity=tc1)
$send diesel.inv.find   (class="TestClass1", key="1234")
$send diesel.inv.update (class="TestClass1", entity=tc1)
$send diesel.inv.delete (class="TestClass1", key="1234")

If the class can be inferred, it can be left out (for instance the entity knows it's class).

The query and listAll return a structure with two fields:

  • total number of results
  • data - an array of results

Rules based inventories

To use rules based inventories, register the following:

$send diesel.inv.register(inventory="diesel", classes="TestClass1")
$send diesel.inv.connect(inventory="diesel", connection="default")

Was this useful?    

By: Razie | 2020-12-04 .. 2022-03-25 | Tags: academy , reference

Viewed 103 times ( | History | Print ) this page.

You need to log in to post a comment!

© Copyright DieselApps, 2012-2022, all rights reserved.