You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sl...@apache.org on 2012/11/14 10:39:53 UTC
[3/3] git commit: update CQL3 doc for collections & ttls
update CQL3 doc for collections & ttls
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/a6c34815
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/a6c34815
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/a6c34815
Branch: refs/heads/cassandra-1.2
Commit: a6c3481525067f2b2e3c3ab7de8c38b0cef08a82
Parents: 228d1cf
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Wed Nov 14 10:38:45 2012 +0100
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Wed Nov 14 10:38:45 2012 +0100
----------------------------------------------------------------------
doc/cql3/CQL.textile | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/a6c34815/doc/cql3/CQL.textile
----------------------------------------------------------------------
diff --git a/doc/cql3/CQL.textile b/doc/cql3/CQL.textile
index 1702e07..514473d 100644
--- a/doc/cql3/CQL.textile
+++ b/doc/cql3/CQL.textile
@@ -761,11 +761,20 @@ bc(sample).
INSERT INTO users (id, given, surname, favs)
VALUES ('jsmith', 'John', 'Smith', { 'fruit' : 'apple', 'band' : 'Beatles' })
-Adding or updating key-values of a (potentially) existing map can be accomplished by subscripting the map column in an @UPDATE@ statement.
+Adding or updating key-values of a (potentially) existing map can be accomplished either by subscripting the map column in an @UPDATE@ statement or by adding a new map literal:
bc(sample).
// Updating (or inserting)
UPDATE users SET favs['author'] = 'Ed Poe' WHERE id = 'jsmith'
+UPDATE users SET favs = favs + { 'movie' : 'Cassablanca' } WHERE id = 'jsmith'
+
+Note that TTLs are allowed for both @INSERT@ and @UPDATE@, but in both case the TTL set only apply to the newly inserted/updated _values_. In other words,
+
+bc(sample).
+// Updating (or inserting)
+UPDATE users USING TTL 10 SET favs['color'] = 'green' WHERE id = 'jsmith'
+
+will only apply the TTL to the @{ 'color' : 'green' }@ record, the rest of the map remaining unaffected.
Deleting a map record is done with:
@@ -796,6 +805,7 @@ bc(sample).
UPDATE images SET tags = tags + { 'cute', 'cuddly' } WHERE name = 'cat.jpg';
UPDATE images SET tags = tags - { 'lame' } WHERE name = 'cat.jpg';
+As with "maps":#map, TTLs if used only apply to the newly inserted/updated _values_.
h4(#list). Lists
@@ -830,6 +840,8 @@ UPDATE plays SET scores[1] = 7 WHERE id = '123-afde'; // sets the
DELETE scores[1] FROM plays WHERE id = '123-afde'; // deletes the 2nd element of scores (raises an error is scores has less than 2 elements)
UPDATE plays SET scores = scores - [ 12, 21 ] WHERE id = '123-afde'; // removes all occurences of 12 and 21 from scores
+As with "maps":#map, TTLs if used only apply to the newly inserted/updated _values_.
+
h2(#appendixA). Appendix A: CQL Keywords