Changes between Version 2 and Version 3 of NifDB


Ignore:
Timestamp:
Apr 17, 2012, 10:03:40 AM (13 years ago)
Author:
manualwiki
Comment:

added some more example to NifDB

Legend:

Unmodified
Added
Removed
Modified
  • NifDB

    v2 v3  
    3434}}} 
    3535 
     36After the system started, you can use is it like with the MNESIA database backend, 
     37but with the NIF graph backend there are some extra functions. 
     38(For further informations see: [[ErlangShellInterface|ri]]) 
     39 
     40= Backup-system example = 
     41 
    3642After the system is started, the following operations work on the full database. 
    3743 
     
    6672ri:ls_backups(). 
    6773 
    68 % Undo all changes made since the last backup. 
     74% Undo all changes made since the last backup. So it will load backup.2. 
    6975ri:undo(). 
     76 
     77% You can restore a certain backup. 
     78% Here you can specify the backup as in ri:backup_info/1. 
     79ri:restore(1). 
    7080 
    7181% Removes all backups. 
     
    7383}}} 
    7484 
    75 You can also use all [[SemanticQuery|querying]] and [[RefactoringSteps|refactoring functionalities]]. 
     85= Graph operations example = 
     86With the NIF database, you may have more graphs. 
     87The graphs does not affect each other, so every graph has its own database, and 
     88backups, etc. After restarting the tool, the last used graph will be loaded. 
     89Let's see an example: 
     90 
     91{{{ 
     92% By default a refactorerl_0 named graph created. 
     93% So after the first startup, the ri:actual_graph/0 
     94% operation should print refactorerl_0.  
     95ri:actual_graph(). 
     96refactorerl_0 
     97 
     98% Now create a graph. The name of the graph must be an atom. 
     99ri:create_graph(graph_name). 
     100 
     101% You can list the created graphs. 
     102ri:ls_graphs(). 
     103[graph_name, refactorerl_0] 
     104 
     105% Load the previously created graph. 
     106ri:load_graph(graph_name). 
     107ok 
     108ri:actual_graph(). 
     109graph_name 
     110 
     111% You may want rename the refactorerl_0 graph to someting else. 
     112% You can even rename the actual graph. 
     113ri:rename_graph(refactorerl_0, some_other_name). 
     114ok 
     115ri:ls_graphs(). 
     116[graph_name, some_other_name] 
     117 
     118% Now delete the graph which is not loaded. 
     119% Of course, you cannot delete the actual graph. 
     120% Warning: It deletes the whole graph from the disk, 
     121% so it cannot be recovered later. 
     122ri:delete_graph(some_other_name). 
     123 
     124% Or you can just delete all graphs. 
     125% After the deletion, it creates the default refactorerl_0 graph. 
     126ri:delete_all_graphs(). 
     127ok 
     128ri:ls_graphs(). 
     129refactorerl_0 
     130 
     131}}} 
     132 
     133If something happened to database, then after startup you will get a message about it 
     134and a new default graph will be created. If refactorerl_0 exists, then refactorerl_1 will 
     135be created, and so on. The corrupted database will not be deleted by the system. 
     136If the user wants to load a corrupted backup, then the system will print an error message, 
     137and the backup will have a 'corrutped_' prefix (so the system renames it), and the graph 
     138will remain the same. 
    76139 
    77140= Comparison with the Mnesia back-end =