@@ -88,16 +88,38 @@ lev --batch '[
8888```
8989or from a file
9090``` sh
91+ # there should be one entry per line
92+ # either as valid JSON
9193echo ' [
9294{"type":"del","key":"father"},
9395{"type":"put","key":"name","value":"Yuri Irsenovich Kim"},
9496{"type":"put","key":"dob","value":"16 February 1941"},
9597{"type":"put","key":"spouse","value":"Kim Young-sook"},
9698{"type":"put","key":"occupation","value":"Clown"}
9799]' > ops.json
100+ # or as newline-delimited JSON
101+ echo '
102+ {"type":"del","key":"father"}
103+ {"type":"put","key":"name","value":"Yuri Irsenovich Kim"}
104+ {"type":"put","key":"dob","value":"16 February 1941"}
105+ {"type":"put","key":"spouse","value":"Kim Young-sook"}
106+ {"type":"put","key":"occupation","value":"Clown"}
107+ ' > ops.json
98108lev --batch ./ops.json
99109```
100110
111+ If the type is omitted, defaults to ` put ` , which allows to use the command to do imports/exports, in combination with [ ` --all ` ] ( #--all ) :
112+ ``` sh
113+ lev --all > leveldb.export
114+ lev /tmp/my-new-db --batch leveldb.export
115+ ```
116+ If it's a large export, you can compress it on the fly
117+ ``` sh
118+ lev --all | gzip -9 > leveldb.export.gz
119+ gzip -dk leveldb.export.gz
120+ lev /tmp/my-new-db --batch leveldb.export
121+ ```
122+
101123## --keys
102124List all the keys in the current range. Will tabularize the output by default (see ` --line ` ).
103125``` sh
@@ -117,6 +139,11 @@ Emit as a new-line delimited stream of json.
117139``` sh
118140lev --all
119141```
142+ It can be used to create an export of the database, to be imported with [ ` --batch ` ] ( #--batch )
143+ ``` sh
144+ lev --all > leveldb.export
145+ lev /tmp/my-new-db --batch leveldb.export
146+ ```
120147
121148## --start < ; key-pattern> ;
122149Specify the start of the current range. You can also use ` gt ` or ` gte ` .
0 commit comments