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.

Changelog

The changelog can be activated by setting the structr.conf switch application.changelog.enabled to true. A Structr instance started with changelog enabled keeps a record of every modification of an entity. There are different kinds of actions (called verb) for which a record is kept.

The changelog itself can be retrieved using the builtin changelog() function. The changelog is written to disk at changelog.path in a subfolder n for nodes and r for relationships.
If user-centric changelog (application.changelog.user_centric.enabled) is enabled the changelog is written to the subfolder u. In older versions of structr the changelog was written to the structrChangeLog property of a node.
The following tables show the possible keys/values of modification records. Modification records are stored as a JSON string. (see the example below)

Verb Event type Keys in changeset
create Creation of an object verb,time,userId,userName,target
delete Deletion of an object verb,time,userId,userName,target
link A relationship to/from another object has been created verb,time,userId,userName,target, rel
unlink A relationship to/from another object has been removed verb,time,userId,userName,target, rel
change One of the properties of the object has been changed verb,time,userId,userName,key, prev, val
Key Content
verb type of changelog event (One of create, change, delete, link, unlink)
time Timestamp of the change (ms since epoch)
userId id of the user, 00000000000000000000000000000000 for SuperUser, null for anonymous
userName name of the user who triggered the modification
target id of the target node of the new or deleted relationship
relId id created/deleted relationship
rel relationship type of the created/deleted relationship
relDir relationship direction of the created/deleted relationship (in/out)
key Property key of the modified property
prev Previous value of the modified property
val New value of the modified property
Example
{"time":1455195862431,"userId":"f02e59a47dc9492da3e6cb7fb6b3ac25","userName":"admin","verb":"change","key":"name","prev":null,"val":"My new name"}
{"time":1455195903852,"userId":"f02e59a47dc9492da3e6cb7fb6b3ac25","userName":"admin","verb":"change","key":"name","prev":"My new name","val":"New Name"}
{"time":1455196049579,"userId":"f02e59a47dc9492da3e6cb7fb6b3ac25","userName":"admin","verb":"link","rel":"has","relId":"97d26b5778b54d3d991bba5026eb615e","relDir":"out","target":"4e32a9f6eb764d86be3de2faacbd7a6a"}
{"time":1455195961348,"userId":"f02e59a47dc9492da3e6cb7fb6b3ac25","userName":"admin","verb":"unlink","rel":"has","relId":"97d26b5778b54d3d991bba5026eb615e","relDir":"out","target":"4e32a9f6eb764d86be3de2faacbd7a6a"}
{"time":1455196115875,"userId":"00000000000000000000000000000000","userName":"superadmin","verb":"unlink","rel":"OWNS","relId":"b29e98329fb949b798162b88864aa038","relDir":"out","target":"f02e59a47dc9492da3e6cb7fb6b3ac25"}

Search results for "Changelog"

changelog()

Returns the changelog for a specific entity. See Changelog for details on what the contents of a changelog are.

The resolve parameter controls if remote entities are resolved. Every changelog entry which has a target will be resolved as targetObj (if the remote entity still exists in the database).

Filtering (supported from version 2.2)
All filter options are chained using the boolean AND operator. Only changelog entries matching all of the specified filters will be returned.
For filter keys which can occurr more than once, the filter values are combined using the boolean OR operator (see examples 1 and 2)

Filter Key Applicable Changlog verbs (*) Changelog Entry will be returned if max. occurrences
timeFrom (**) create, delete, link, unlink, change timeFrom <= time of the entry 1 (***)
timeTo (**) create, delete, link, unlink, change timeTo >= time of the entry 1 (***)
verb create, delete, link, unlink, change verb of the entry matches at least one of the verbs n (****)
userId create, delete, link, unlink, change userId of the entry matches at least one of the userIds n (****)
userName create, delete, link, unlink, change userName of the entry matches at least one of the userNames n (****)
relType link, unlink rel of the entry matches at least one of the relTypes n (****)
relDir link, unlink relDir of the entry matches the given relDir 1 (***)
target create, delete, link, unlink target of the entry matches at least one of the targets n (****)
key change key of the entry matches at least one of the keys n (****)

(*) If a filter parameter is supplied, only changelog entries can be returned to which it is applicable. (e.g. combining key and relType can never yield a result as they are mutually exclusive)
(**) timeFrom/timeTo can be specified as a Long (time in ms since epoch), as a JavaScript Date object, or as a String with the format yyyy-MM-dd'T'HH:mm:ssZ
(***) The last supplied parameter takes precedence over the others
(****) The way we supply multiple occurrences of a keyword can differ from StructrScript to JavaScript

changelog(entity [, resolve=false [, filterKey1, filterValue2 [ , ... ] ] ] )
$.changelog(entity [, resolve=false [, map]])

user_changelog()

Returns the changelog for the changes a specific user made.

user_changelog(user [, resolve=false [, filterKey1, filterValue2 [ , ... ] ] ] )
$.user_changelog(user [, resolve=false [, map]])

Changelog

The changelog itself can be retrieved using the builtin changelog() function. The changelog is written to disk at changelog.path with the subfolders n for nodes and r for relationships. If user-centric changelog (application.changelog.user_centric.enabled) is enabled the changelog is written to the subfolder u. In older versions of structr the changelog was written to the structrChangeLog property of a node. The following tables show the possible keys/values of modification records. Modification records are stored as a JSON string. (see the example below)

application.changelog.enabled If enabled, all changes to nodes and relationships will be written to a changelog.
application.changelog.user_centric.enabled Enables a special kind of changelog, which logs user activities.

The changelog can be activated by setting the structr.conf switch application.changelog.enabled to true. A Structr instance started with changelog enabled keeps a record of every modification of an entity. There are different kinds of actions (called verb) for which a record is kept.

Paths

base.path Path of the Structr working directory. All files will be located relative to this directory.
tmp.path Path to the temporary directory. Uses java.io.tmpdir by default.
database.path Path of the Neo4j db/ directory.
files.path Path to the Structr file storage folder.
changelog.path Path to the Structr changelog storage folder.
data.exchange.path Path to the exchange directory. This path is relative to the base path of the Structr installation to prevent access to files outside of the installation directory. The exchange directory is used by the I/O built-in functions read, write and append.
snapshot.path Path to the snapshot directory. This path is relative to the base path of the Structr installation to prevent access to files outside of the installation directory. The snapshot directory is used by the snapshot() built-in function that allows you to read / write the schema of your application from / to a JSON file.
data.webapp.path Path to the webapp directory. This path is relative to the base path of the Structr installation to prevent access to files outside of the installation directory. The webapp directory is used by the internal web server to serve resource files needed by the Structr UI.

Changelog

The file-based changelog can consist of many files. You should make sure the file system can handle the amount of files. Depending on the file system it can happen that no more files can be written even if enough space is available.

Key Content
verb type of changelog event (One of create, change, delete, link, unlink)
time Timestamp of the change (ms since epoch)
userId id of the user, 00000000000000000000000000000000 for SuperUser, null for anonymous
userName name of the user who triggered the modification
target id of the target node of the new or deleted relationship
relId id created/deleted relationship
rel relationship type of the created/deleted relationship
relDir relationship direction of the created/deleted relationship (in/out)
key Property key of the modified property
prev Previous value of the modified property
val New value of the modified property

Neo4j Upgrade

Structr 4.x still supports neo4j 3.5, so an upgrade is not strictly necessary. If an upgrade to a more recent neo4j version is desired, the neo4j changelog and migration guide should be consulted before upgrading. Some deprecated features have been removed in neo4j 4.x, so one should be on the lookout. One resource one should consult is: https://neo4j.com/docs/cypher-manual/current/deprecations-additions-removals-compatibility/#cypher-compatibility

A prominent example is that the cypher parameter syntax has changed:

sync