2024-11-08 21:52:53 -08:00

64 lines
1.7 KiB
Objective-C
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// RSDatabaseQueue.h
// RSDatabase
//
// Created by Brent Simmons on 10/19/13.
// Copyright (c) 2013 Ranchero Software, LLC. All rights reserved.
//
@import Foundation;
#import "FMDatabase.h"
// This has been deprecated — use DatabaseQueue instead.
@class RSDatabaseQueue;
NS_ASSUME_NONNULL_BEGIN
@protocol RSDatabaseQueueDelegate <NSObject>
@optional
- (void)makeFunctionsForDatabase:(FMDatabase *)database queue:(RSDatabaseQueue *)queue;
@end
// Everything runs on a serial queue.
typedef void (^RSDatabaseBlock)(FMDatabase * __nonnull database);
@interface RSDatabaseQueue : NSObject
@property (nonatomic, strong, readonly) NSString *databasePath; // For debugging use, so you can open the database in sqlite3.
- (instancetype)initWithFilepath:(NSString *)filepath excludeFromBackup:(BOOL)excludeFromBackup;
@property (nonatomic, weak) id<RSDatabaseQueueDelegate> delegate;
// You can feed it the contents of a file that includes comments, etc.
// Lines that start with case-insensitive "create " are executed.
- (void)createTablesUsingStatements:(NSString *)createStatements;
- (void)createTablesUsingStatementsSync:(NSString *)createStatements;
- (void)update:(RSDatabaseBlock)updateBlock;
- (void)updateSync:(RSDatabaseBlock)updateBlock;
- (void)runInDatabase:(RSDatabaseBlock)databaseBlock; // Same as update, but no transaction.
- (void)fetch:(RSDatabaseBlock)fetchBlock;
- (void)fetchSync:(RSDatabaseBlock)fetchBlock;
- (void)vacuum;
- (void)vacuumIfNeeded; // defaultsKey = @"lastVacuumDate"; interval is 6 days.
- (void)vacuumIfNeeded:(NSString *)defaultsKey intervalBetweenVacuums:(NSTimeInterval)intervalBetweenVacuums;
- (NSArray *)arrayWithSingleColumnResultSet:(FMResultSet *)rs;
- (void)close;
@end
NS_ASSUME_NONNULL_END