System Runtime

System Runtime

  • Languages iconENGLISH
    • Română
    • Help Translate
  • SUPPORT
  • GITHUB

›Guides

Introduction

  • What is System Runtime ?
  • System Runtime architecture
  • What is Design First ?
  • Overview

Guides

  • Quick Start
  • How to install System Runtime
  • Design your model
  • Create components
  • Manage your components
  • Bundle your system
  • Extend System Runtime
  • Go deeper

Examples

  • A basic "hello world"
  • Create a bundle
  • Install a bundle client-side
  • Install a bundle in HTML
  • Install a bundle server-side
  • Package a bundle
  • Create a component
  • Create new types
  • Create a one to one relationship
  • Create a one to many relationship
  • Navigate through the model
  • Inheritance between components
  • Listen to a change of state of a component
  • Use System Runtime NoSQL Database
  • Object-Document Mapper in action
  • Use System Runtime core apis
  • Use System Runtime history apis
  • Quick Start example

APIS

  • Component Class
  • runtime Component
  • metamodel Component
  • logger Component
  • db Component
  • history Component
  • Document Collection

About

  • Who is behind System Runtime ?
  • License

Manage your components

A component is a NoSQL Document

All objects are a component in Runtime:

  • a class is a component,
  • an instance of a class is a component,
  • a behavior is a component,
  • all the core objects of System Runtime (runtime, db, metamodel and admin) are components.

All these components are stores in System Runtime NoSQL DB. In fact, System Runtime acts as an ODM (Object-Document Mapper) to manage your components as NoSQL Documents.

Use System Runtime NoSQL Database

To use System Runtime NoSQL DB, just require db component:

runtime.require('db');

All collections of System Runtime NoSQL DB are the schemas you have created.

const metamodel = runtime.require('metamodel');

// create Person schema
metamodel.schema('Person');

metamodel.create();

// count the number of document in Person collection
runtime.require('db').collections().Person.count();

Find a component

To find the a component with NoSQL DB, you have just to use find method on the related collection:

const metamodel = runtime.require('metamodel');

// create a Person schema
metamodel.schema('Person', {
  'firstName': 'property',
  'lastName': 'property'
});

metamodel.create();

// create a Person component
const Person = runtime.require('Person');
const luke = new Person({
  'firstName': 'Luke',
  'lastName': 'Skywalker'
});

// find the related document
const documents = runtime.require('db').collections().Person.find({ 
  'lastName': 'Skywalker'
});

Create a component

To create a component with NoSQL DB, you have just to use insert method on the related collection:

const metamodel = runtime.require('metamodel');

// create Person schema
metamodel.schema('Person', {
  'firstName': 'property',
  'lastName': 'property'
});

metamodel.create();

// create a Person document
runtime.require('db').collections().Person.insert({
  '_id': 'luke',
  'firstName': 'Luke',
  'lastName': 'Skywalker'
});

// a component has been created
// and you can require it
const luke = runtime.require('luke');

luke.firstName();

Update a component

To update a component with NoSQL DB, you have just to use update method on the related collection:

const metamodel = runtime.require('metamodel');

// create Person schema
metamodel.schema('Person', {
  'firstName': 'property',
  'lastName': 'property'
});

metamodel.create();

// create a Person component
const Person = runtime.require('Person');

const luke = new Person({
  'firstName': 'Luke',
  'lastName': 'Skywalker'
});

// update the related document
runtime.require('db').collections().Person.update(
  {
    '_id': luke.id()
  }, 
  { 
    'lastName': 'Starkiller'
  }
);

// property of the component has changed
luke.lastName();

Delete a component

To update a component with NoSQL DB, you have just to use remove method on the related collection:

const metamodel = runtime.require('metamodel');

// create Person schema
metamodel.schema('Person', {
  'firstName': 'property',
  'lastName': 'property'
});

metamodel.create();

// create a Person component
const Person = runtime.require('Person');

const luke = new Person({
  'firstName': 'Luke',
  'lastName': 'Skywalker'
});

// remove the related document
runtime.require('db').collections().Person.remove({
  '_id': luke.id()
});

// try to use the component
luke.lastName();

System Runtime generates this error:

runtime: trying to get the property 'lastName' on the destroyed component '1238d1105

Conclusion

We saw on this article that:

  • everything is a component in System Runtime,
  • you use System Runtime NoSQL DB to find, create, update or delete a component.

In the next article we will talk about systems.

← Create componentsBundle your system →
  • A component is a NoSQL Document
  • Use System Runtime NoSQL Database
  • Find a component
  • Create a component
  • Update a component
  • Delete a component
  • Conclusion
System Runtime is distributed under Apache License 2.0 - Copyright © 2024 Erwan Carriou