upcoming_calendar

Find all calendar events for a particular year and month.

Find all calendar events for a particular year and month.

SOURCE '0_create_keyspace.cql';

DROP TABLE IF EXISTS cycling.upcoming_calendar;

// Find all calendar events for a particular year and month
// START-listColumn
CREATE TABLE IF NOT EXISTS cycling.upcoming_calendar (
  year int,
  month int,
  events list<text>,
  PRIMARY KEY (year, month)
);
// END-listColumn

// START-add_tour
INSERT INTO cycling.upcoming_calendar (
  year, month, events
) VALUES (
  2015, 06, [ 'Criterium du Dauphine', 'Tour de Suisse' ]
);
// END-add_tour

INSERT INTO cycling.upcoming_calendar (
  year, month, events
) VALUES (
  2015, 07, [ 'Tour de France' ]
);

// START-delete
DELETE events[0]
FROM cycling.upcoming_calendar
WHERE year = 2015
  AND month = 07;
// END-delete

// START-remove
UPDATE cycling.upcoming_calendar
SET events = events - ['Tour de France Stage 10']
WHERE year = 2015
  AND month = 07;
// END-remove

INSERT INTO cycling.upcoming_calendar (
  year, month, events
) VALUES (
  2015, 07, [ 'Tour de France' ]
);

CAPTURE 'select_all_from_upcoming_calendar.results';
// START-select
SELECT *
FROM cycling.upcoming_calendar;
// END-select
CAPTURE OFF;

// START-insert
UPDATE cycling.upcoming_calendar 
SET events = [ 'Criterium du Dauphine', 'Tour de Suisse' ]
WHERE year = 2015
  AND month = 06;
// END-insert

// START-prepend
UPDATE cycling.upcoming_calendar 
SET events = [ 'Tour de France' ] + events 
WHERE year = 2015
  AND month = 06;
// END-prepend

// START-append
UPDATE cycling.upcoming_calendar 
SET events = events + [ 'Tour de France' ] 
WHERE year = 2017
  AND month = 05;
// END-append

// START-position
UPDATE cycling.upcoming_calendar 
SET events[2] = 'Tour de France' 
WHERE year = 2015
  AND month = 06;
// END-position

// START-set
UPDATE cycling.upcoming_calendar 
SET events[2] = 'Vuelta Ciclista a Venezuela' 
WHERE year = 2015
  AND month = 06;
// END-set

// START-ttl
UPDATE cycling.upcoming_calendar 
USING TTL 10000000
SET events[2] = 'Vuelta Ciclista a Venezuela' 
WHERE year = 2015
  AND month = 06;
// END-ttl

// START-addcolumn
ALTER TABLE cycling.upcoming_calendar 
ADD description map<text,text>;
// END-addcolumn

// START-example
UPDATE cycling.upcoming_calendar 
SET description = description + {
  'Criterium du Dauphine' : 'Easy race', 'Tour du Suisse' : 'Hard uphill race'
}
WHERE year = 2015
  AND month = 6;
// END-example

// START-newrow
UPDATE cycling.upcoming_calendar 
SET description = {
  'Criterium du Dauphine' : 'Easy race', 'Tour du Suisse' : 'Hard uphill race'
} 
WHERE year = 2015
  AND month = 6;
// END-newrow

CAPTURE 'select_description_from_upcoming_calendar.results';
// START-select_description
SELECT description
FROM cycling.upcoming_calendar
WHERE year = 2015
  AND month = 6;
// END-select_description
CAPTURE OFF;

// START-value
UPDATE cycling.upcoming_calendar 
SET events = events - [ 'Tour de France' ] 
WHERE year = 2015
  AND month = 06;
// END-value

// START-map
UPDATE cycling.upcoming_calendar 
SET description = description + {
  'Criterium du Dauphine' : 'Easy race'
} 
WHERE year = 2015
  AND month = 06;
// END-map