/
a-shell-example.html
102 lines (90 loc) · 2.98 KB
/
a-shell-example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!DOCTYPE html>
<html>
<head>
<title>Caltech Library's Digital Library Development Sandbox</title>
<link rel="stylesheet" href="/css/site.css">
</head>
<body>
<header>
<a href="https://library.caltech.edu"><img src="/assets/liblogo.gif" alt="Caltech Library logo"></a>
</header>
<nav>
<ul>
<li>
<a href="/">Home</a>
</li>
<li>
<a href="../">Up</a>
</li>
<li>
<a href="../">README</a>
</li>
<li>
<a href="../license.html">LICENSE</a>
</li>
<li>
<a href="../install.html">INSTALL</a>
</li>
<li>
<a href="../docs/">Documentation</a>
</li>
<li>
<a href="./">Tutorials</a>
</li>
<li>
<a href="../docs/topics.html">Topics</a>
</li>
<li>
<a href="https://github.com/caltechlibrary/dataset">Github</a>
</li>
<li>
<a href="https://github.com/caltechlibrary/dataset/releases/">Releases</a>
</li>
</ul>
</nav>
<section>
<h2 id="a-shell-example">
A Shell Example
</h2>
<p>
Below is a simple example of shell based interaction with dataset a collection using the command line dataset tool.
</p>
<pre class="shell"><code> # Create a collection "friends.ds", the ".ds" lets the bin/dataset command know that's the collection to use.
dataset init friends.ds
# if successful then you should see an OK otherwise an error message
# Create a JSON document
dataset create friends.ds frieda \
'{"name":"frieda","email":"frieda@inverness.example.org"}'
# If successful then you should see an OK otherwise an error message
# Read a JSON document
dataset read friends.ds frieda
# Path to JSON document
dataset path friends.ds frieda
# Update a JSON document
dataset update friends.ds frieda \
'{"name":"frieda","email":"frieda@zbs.example.org", "count": 2}'
# If successful then you should see an OK or an error message
# List the keys in the collection
dataset keys friends.ds
# Join frieda-profile.json with "frieda" adding unique key/value pairs
dataset join friends.ds frieda frieda-profile.json
# Join frieda-profile.json overwriting in commont key/values adding
# unique key/value pairs from frieda-profile.json
dataset join -overwrite friends.ds frieda frieda-profile.json
# Delete a JSON document
dataset delete friends.ds frieda
# Import data from a CSV file using column 1 as key
dataset import friends.ds my-data.csv 1
# To remove the collection just use the Unix shell command
rm -fR friends.ds</code></pre>
</section>
<footer>
<span><h1><A href="https://caltech.edu">Caltech</a></h1></span>
<span>© 2021 <a href="https://www.library.caltech.edu/copyright">Caltech library</a></span>
<address>1200 E California Blvd, Mail Code 1-32, Pasadena, CA 91125-3200</address>
<span>Phone: <a href="tel:+1-626-395-3405">(626)395-3405</a></span>
<span><a href="mailto:library@caltech.edu">Email Us</a></span>
<a class="cl-hide" href="sitemap.xml">Site Map</a>
</footer>
</body>
</html>