From b3c7fec676830f2412b02fc9f9b69f8cb4e16821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Fri, 2 Nov 2018 13:56:52 +0100 Subject: [PATCH] Documentation --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f68be1f46..c689dec52 100644 --- a/README.md +++ b/README.md @@ -7767,7 +7767,7 @@ Only five types adopt those protocols: DatabaseQueue, DatabasePool, DatabaseSnap DatabaseReader and DatabaseWriter provide the *smallest* common guarantees: they don't erase the differences between queues, pools, and snapshots. See for example [Differences between Database Queues and Pools](#differences-between-database-queues-and-pools). -However, you can easily prevent some parts of your application from writing in the database by giving them a DatabaseReader: +However, you can prevent some parts of your application from writing in the database by giving them a DatabaseReader: ```swift // This class can read in the database, but can't write into it. @@ -7783,6 +7783,14 @@ let dbQueue: DatabaseQueue = ... let component = MyReadOnlyComponent(reader: dbQueue) ``` +> :point_up: **Note**: DatabaseReader is not a **secure** way to prevent an application component from writing in the database, because write access is just a cast away: +> +> ```swift +> if let dbQueue = reader as? DatabaseQueue { +> try dbQueue.write { ... } +> } +> ``` + ### Unsafe Concurrency APIs