summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md29
1 files changed, 29 insertions, 0 deletions
diff --git a/README.md b/README.md
index baf7c77..d059a24 100644
--- a/README.md
+++ b/README.md
@@ -122,6 +122,35 @@ The type represents a "row", it can be:
122 122
123Not all types are allowed, see the section "Bind parameters and resultset rows" for more information on the types mapping rules. 123Not all types are allowed, see the section "Bind parameters and resultset rows" for more information on the types mapping rules.
124 124
125The `one` method on a statement works the same way except it returns the first row of the result set:
126
127```zig
128const query =
129 \\SELECT age FROM employees WHERE id = ?
130;
131
132var stmt = try db.prepare(query);
133defer stmt.deinit();
134
135const row = try stmt.one(usize, .{}, .{ .id = 20 });
136if (row) |age| {
137 std.log.debug("age: {}", .{age});
138}
139```
140
141The convienence function `sqlite.Db.one` works exactly the same way:
142
143```zig
144const query =
145 \\SELECT age FROM employees WHERE id = ?
146;
147
148const row = try db.one(usize, query, .{}, .{ .id = 20 });
149if (row) |age| {
150 std.log.debug("age: {}", .{age});
151}
152```
153
125### Bind parameters and resultset rows 154### Bind parameters and resultset rows
126 155
127Since sqlite doesn't have many [types](https://www.sqlite.org/datatype3.html) only a small number of Zig types are allowed in binding parameters and in resultset mapping types. 156Since sqlite doesn't have many [types](https://www.sqlite.org/datatype3.html) only a small number of Zig types are allowed in binding parameters and in resultset mapping types.