apoc.systemdb.export.metadata
|
This is the APOC Extended documentation. APOC Extended is not supported by Neo4j. For the officially supported APOC Core, go to the APOC Core page. |
Procedure Apoc Extended
Signature
apoc.systemdb.export.metadata(config = {} :: MAP?) :: (file :: STRING?, source :: STRING?, format :: STRING?, nodes :: INTEGER?, relationships :: INTEGER?, properties :: INTEGER?, time :: INTEGER?, rows :: INTEGER?, batchSize :: INTEGER?, batches :: INTEGER?, done :: BOOLEAN?, data :: STRING?)
Config parameters
The procedure support the following config parameters:
| name | type | default | description |
|---|---|---|---|
filename |
String |
"metadata" |
The filename prefix. For example, metadata.customProcedures.dbName.cypher |
features |
List<String> |
["CypherProcedure", "CypherFunction", "Uuid", "Trigger", "DataVirtualizationCatalog"] |
A list indicating which functions are to be exported. Possible values are "CypherProcedure", "CypherFunction", "Uuid", "Trigger", "DataVirtualizationCatalog". |
Output parameters
| Name | Type |
|---|---|
file |
STRING? |
source |
STRING? |
format |
STRING? |
nodes |
INTEGER? |
relationships |
INTEGER? |
properties |
INTEGER? |
time |
INTEGER? |
rows |
INTEGER? |
batchSize |
INTEGER? |
batches |
INTEGER? |
done |
BOOLEAN? |
data |
STRING? |
Usage Examples
To use this procedure, we have to enable it by setting the following property in apoc.conf:
apoc.export.file.enabled=true
If we execute in a database neo4j the following queries:
CALL apoc.trigger.add('trig','RETURN $alpha', {phase: 'after'}, {params: {alpha: 1} });
CALL apoc.trigger.add('trigTwo','RETURN 1', null);
CALL apoc.trigger.pause('trigTwo');
CALL apoc.custom.declareFunction('funNameOne(val = 2 :: INTEGER) :: NODE ', 'MATCH (t:Target {value : $val}) RETURN t');
CALL apoc.custom.declareProcedure('procNameOne(one = 2 ::INTEGER?, two = 3 :: INTEGER?) :: (sum :: INTEGER) ', 'RETURN $one + $two as sum');
CALL apoc.custom.asProcedure('procName','RETURN $input as answer','read',[['answer','number']],[['input','int','42']], 'Procedure that answer to the Ultimate Question of Life, the Universe, and Everything');
CALL apoc.custom.asFunction('funName','RETURN $input as answer','long', [['input','number']], false);
CREATE CONSTRAINT person_cons ON (p:Person) ASSERT p.alpha IS UNIQUE;
CALL apoc.uuid.install('Person', {addToSetLabels: true, uuidProperty: 'alpha'});
CALL apoc.dv.catalog.add("dvName", {type: 'CSV', url: 'file://myUrl', query: 'map.name = $name and map.age = $age', desc: "person's details", labels: ['Person']});
and in a database another:
CALL apoc.trigger.add('trigAnother','RETURN 1', null);
If we execute:
CALL apoc.systemdb.export.metadata()
we obtain the following files:
CALL apoc.custom.declareFunction('funNameOne(val = 2 :: INTEGER?) :: (NODE?)', 'MATCH (t:Target {value : $val}) RETURN t' , false, '');
CALL apoc.custom.declareProcedure('procNameOne(one = 2 :: INTEGER?, two = 3 :: INTEGER?) :: (sum :: INTEGER?)', 'RETURN $one + $two as sum' , 'READ', '');
CALL apoc.custom.declareProcedure('procName(input = 42 :: INTEGER?) :: (answer :: NUMBER?)', 'RETURN $input as answer' , 'READ', 'Procedure that answer to the Ultimate Question of Life, the Universe, and Everything');
CALL apoc.custom.declareFunction('funName(input :: NUMBER?) :: (INTEGER?)', 'RETURN $input as answer' , false, '');
CALL apoc.dv.catalog.add('dvName', {name:"dvName",url:"file://myUrl",desc:"person's details",labels:["Person"],query:"map.name = $name and map.age = $age",params:["$name","$age"],type:"CSV"});
CALL apoc.trigger.add('trig', 'RETURN $alpha', {phase:"after"},{params: {alpha:1}});
CALL apoc.trigger.add('trigTwo', 'RETURN 1', null,{params: {}});
CALL apoc.trigger.pause('trigTwo');
CALL apoc.uuid.install('Person', {uuidProperty:"alpha",addToSetLabels:true}) YIELD label RETURN label;
CALL apoc.uuid.install('Person', {uuidProperty:"beta",addToSetLabels:null}) YIELD label RETURN label;
CREATE CONSTRAINT IF NOT EXISTS ON (n:Person) ASSERT n.alpha IS UNIQUE;
CREATE CONSTRAINT IF NOT EXISTS ON (n:Person) ASSERT n.beta IS UNIQUE;
So that we can import everything in another db, with the apoc.cypher.run* procedures:
CALL apoc.cypher.runSchemaFile("metadata.uuids.schema.neo4j.cypher");
CALL apoc.cypher.runFiles(["metadata.customProcedures.neo4j.cypher", "metadata.dvCatalogs.neo4j.cypher", "metadata.triggers.neo4j.cypher", "metadata.uuids.neo4j.cypher"])
We can choose what we want to export with config parameter features (this is a list of strings with possible values "customProcedures", "triggers", "uuids", "dvCatalogs").
For example with:
CALL apoc.systemdb.export.metadata({features: ["triggers", "uuids"]})
will be exported only metadata.triggers.neo4j.cypher and metadata.uuids.neo4j.cypher files.
Therefore, we can choose the file name prefix, for example if we want to export files with names customName.triggers.neo4j.cypher, etc…, we can do:
CALL apoc.systemdb.export.metadata({filename: "customName"})