summaryrefslogtreecommitdiffstats
path: root/doc/src/notifications.qdoc
blob: 36a709f9ffca0eff5bb885be80fd10bf6632d769 (plain)
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
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
\page notifications.html
\title Notifications

JSON DB clients can register to be informed about changes in the database via
notifications. Clients create notifications containing a query to monitor.
When an object matching the query is modified, JSON DB sends a notification
message to the client.

Notifications are registered via the \l {QJsonDbWatcher} class in C++ and
via the \l {Notification} item in QML.

Notifications usually pertain to new events in the database, but by using the
\l {QJsonDbWatcher::initialStateNumber} property, it's possible to request
notifications based on past events in the database. This can be useful in
writing a program that would need to synchronize with the database.

\section1 Actions

Clients may register to receive notifications based on one or more types
of actions that may occur in the database. The available actions are:

\table
\row
\row
\li Created
\li Notifications with this action generally represent entirely new objects
which match the specified query being created in the database. Another case is an
existing object which previously did not match the query being modified to now
match the query.

\row
\li Updated
\li Notifications with this action represent an object that matches the
specified query being updated (while still matching the query).

\row
\li Removed
\li Notifications with this action generally represent an existing object which
matches the specified query being removed from the database. Another case is an
existing object which previously matched the query being modified so that it no
longer matches the query. Whether the object has been removed or not can be
tested by checking if the object in the notification has a \c _deleted property
with the value of \c true.

\row
\li StateChanged
\li Used for historical notifications only. When this action is received, it
means that the last notification for a particular state (transaction) has been
received.

\endtable

\section1 Lifecycle

Under-the-hood, both \l {QJsonDbWatcher} and \l {Notification} function by
creating an object of type \c notification in the Ephemeral partition (see
\l {Partitions}). Once the object is created, notifications can begin being
sent. When a connection to the database drops, all of the notifications for
that connection are removed.
*/