Database

Encryption

  • Sets the passphrase used to crypt and decrypt an SQLCipher database.

    Call this method from Configuration.prepareDatabase, as in the example below:

    var config = Configuration()
    config.prepareDatabase { db in
        try db.usePassphrase("secret")
    }
    
  • Changes the passphrase used by an SQLCipher encrypted database.

  • Deletes the synchronization triggers for a synchronized FTS5 table

FTS5

  • Add a custom FTS5 tokenizer.

    class MyTokenizer : FTS5CustomTokenizer { ... }
    db.add(tokenizer: MyTokenizer.self)
    
  • Creates a pattern from a raw pattern string; throws DatabaseError on invalid syntax.

    The pattern syntax is documented at https://www.sqlite.org/fts5.html#full_text_query_syntax

    try db.makeFTS5Pattern(rawPattern: "and", forTable: "document") // OK
    try db.makeFTS5Pattern(rawPattern: "AND", forTable: "document") // malformed MATCH expression: [AND]
    
  • Creates an FTS5 tokenizer, given its descriptor.

    let unicode61 = try db.makeTokenizer(.unicode61())
    

    It is a programmer error to use the tokenizer outside of a protected database queue, or after the database has been closed.

    Use this method when you implement a custom wrapper tokenizer:

    final class MyTokenizer : FTS5WrapperTokenizer {
        var wrappedTokenizer: FTS5Tokenizer
    
        init(db: Database, arguments: [String]) throws {
            wrappedTokenizer = try db.makeTokenizer(.unicode61())
        }
    }