1.0.0 • Published 6 years ago

mongowb v1.0.0

Weekly downloads
3
License
Apache
Repository
github
Last release
6 years ago

MongoWB™

An expression evaluator that wants to be like MongoDB.

  • Object that has a MongoWB™ operations as a property
  • The parameters of the operation are in the value.

$concat

  • Argument: array
  • Arrays, MongoWB™, or elements
  • Returns an array

$foreach

  • Argument: object
    • object.$collection: Array, MongoWB™, FormulaValues™
    • object.$template: MongoWB™, FormulaValues™

Example:

{
	"_id": "A",
  "name": "Recojo de almacén",
  "input": [
    {
      "name": "fecha",
      "type": "datetime",
      "required": true
    },
    {
      "name": "posts",
      "type": "post",
      "multiplicity": "1..*"
    }
  ],
  "context_processing": [ // name to be defined
    {
      "type": "sushi",
      "sources": {
        "collection": "={{posts}}",
	      "recipe": [
	      	// ...
	      ]
      },
      "destination": "pedidos",
    }
  ],
  "template": {
    "text": "Recoger material de almacén",
    "todos": {
    	"$concat": [
    		{
    			"$foreach": {
    				"$collection": "={{pedidos}}",
    				"$template": {
    					"text": "Recoger {{$item.cantidad}} {{$item.producto}}"
    				}
    			}
    		},
    		{
    			"text": "Firmar pedidos"
    		}
    	]
    }
  }
}

Test

npm test