You have been redirected from an outdated version of the article. Below is the content available on this topic. To view the old article click here.

create()

Usage

create(type, key1, value1, key2, value2)
create(type, key, value)
create(type)

Structr.create(type, key1, value1, key2, value2);
Structr.create(type, {key1: value1, key2: value2});

Description
Creates a new node of the given Type with the given value(s) for the given key(s). This method can be used with multiple key-value pairs. The return value is the newly created entity. See also delete().
In a JavaScript environment, the function can be used just as in a StructrScript environment. Alternatively it can take a dictionary as the second parameter.

Example

${create('User', 'name', 'tester3')}

results in

ab6fcef53dd24793bfa67754f414c61e

Search results for "create()"

get_or_create()

get_or_create() finds and returns a single object with the given properties (key/value pairs or a map of properties) and creates that object if it does not exist yet.
The function accepts three different parameter combinations, where the first parameter is always the name of the type to retrieve from the database. The second parameter can either be a map (e.g. a result from nested function calls) or a list of (key, value) pairs.

get_or_create(type [, key1, value1, [, ...] ])
get_or_create(type [, map ])

create()

Creates a new node of the given type with the given value(s) for the given key(s). This method can be used with multiple key-value pairs. The return value is the newly created entity. See also delete().

create(type [, key1, value1 , ... ])
$(type [, map ]);

Import from Webservices

Structr provides a number of built-in functions to access external data sources and transform the data: GET, PUT, POST, from_csv, from_json, from_xml. You can then use JavaScript to process the results and create objects using the create() function mentioned in the previous section.

Create Nodes

To create nodes in a scripting environment, you can use the create() function. The create function uses a syntax very similar to the request body of a REST POST request as shown in the following Javascript example.