forked from imkerberos/FMDBx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cbc53e2
Showing
85 changed files
with
9,011 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.DS_Store | ||
*.xcodeproj/* | ||
!*.xcodeproj/project.pbxproj | ||
!*.xcworkspace/contents.xcworkspacedata | ||
*.xcworkspace/xcuserdata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# | ||
# Be sure to run `pod spec lint FMDBx.podspec' to ensure this is a | ||
# valid spec and to remove all comments including this before submitting the spec. | ||
# | ||
# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html | ||
# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ | ||
# | ||
|
||
Pod::Spec.new do |s| | ||
|
||
s.name = "FMDBx" | ||
s.version = "0.0.1" | ||
s.summary = "An extension of FMDB. Provides ORM and migration functionality." | ||
s.homepage = "https://github.com/kohkimakimoto/FMDBx" | ||
s.license = { :type => 'MIT', :file => 'LICENSE' } | ||
s.author = { 'Kohki Makimoto' => '[email protected]' } | ||
s.source = { :git => 'https://github.com/kohkimakimoto/FMDBx.git', :tag => s.version.to_s } | ||
s.source_files = 'Classes/*.{h,m}' | ||
s.library = 'sqlite3' | ||
s.requires_arc = true | ||
s.platform = :ios | ||
s.dependency 'FMDB' | ||
|
||
end |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#import "FMXDatabaseConfiguration.h" | ||
#import "FMXDatabaseManager.h" | ||
#import "FMXDatabaseMigration.h" | ||
#import "FMXHelpers.h" | ||
#import "FMXModel.h" | ||
#import "FMXTableMap.h" | ||
#import "FMXColumnMap.h" | ||
#import "FMXQuery.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// FMXColumnMap.h | ||
// FMDBx | ||
// | ||
// Copyright (c) 2014 KohkiMakimoto. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
typedef NS_ENUM(NSInteger, FMXColumnMapType) { | ||
FMXColumnMapTypeInt = 0, | ||
FMXColumnMapTypeLong, | ||
FMXColumnMapTypeDouble, | ||
FMXColumnMapTypeString, | ||
FMXColumnMapTypeBool, | ||
FMXColumnMapTypeDate, | ||
FMXColumnMapTypeData | ||
}; | ||
|
||
@interface FMXColumnMap : NSObject | ||
|
||
@property (strong, nonatomic) NSString *name; | ||
@property (assign, nonatomic) FMXColumnMapType type; | ||
@property (assign, nonatomic) BOOL increments; | ||
|
||
- (id)initWithName:(NSString *)name type:(FMXColumnMapType)type; | ||
- (NSString *)propertyName; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// FMXColumnMap.m | ||
// FMDBx | ||
// | ||
// Copyright (c) 2014 KohkiMakimoto. All rights reserved. | ||
// | ||
|
||
#import "FMXColumnMap.h" | ||
#import "FMXHelpers.h" | ||
|
||
@implementation FMXColumnMap | ||
|
||
- (id)initWithName:(NSString *)name type:(FMXColumnMapType)type | ||
{ | ||
self = [super init]; | ||
if (self) { | ||
self.name = name; | ||
self.type = type; | ||
self.increments = NO; | ||
} | ||
return self; | ||
} | ||
|
||
-(NSString *)propertyName | ||
{ | ||
return FMXLowerCamelCaseFromSnakeCase(self.name); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// FMXDatabaseConfigration.h | ||
// FMDBx | ||
// | ||
// Copyright (c) 2014 KohkiMakimoto. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "FMDatabase.h" | ||
|
||
|
||
@class FMXModelRepository; | ||
|
||
@interface FMXDatabaseConfiguration : NSObject | ||
|
||
@property (strong, nonatomic) NSString *databasePath; | ||
@property (strong, nonatomic) NSString *databasePathInDocuments; | ||
|
||
- (id)initWithDatabasePath:(NSString *)databasePath; | ||
|
||
- (FMDatabase *)database; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// FMXDatabaseConfigration.m | ||
// FMDBx | ||
// | ||
// Copyright (c) 2014 KohkiMakimoto. All rights reserved. | ||
// | ||
|
||
#import "FMXDatabaseConfiguration.h" | ||
|
||
@implementation FMXDatabaseConfiguration | ||
|
||
/** | ||
* Setup new database configuration with database path. | ||
* | ||
* @param databasePath database path | ||
* @return FMXDatabaseConfiguration instance. | ||
*/ | ||
- (id)initWithDatabasePath:(NSString *)databasePath | ||
{ | ||
self = [super init]; | ||
if (self) { | ||
self.databasePath = databasePath; | ||
|
||
// Set a database file path in the documents directory. | ||
NSString *dir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; | ||
self.databasePathInDocuments = [dir stringByAppendingPathComponent:databasePath]; | ||
|
||
// Initialize database file. | ||
NSFileManager *fm = [NSFileManager defaultManager]; | ||
if (![fm fileExistsAtPath:self.databasePathInDocuments]) { | ||
// The database file is not found in the documents directory. Create empty database file. | ||
[fm createFileAtPath:self.databasePathInDocuments contents:nil attributes:nil]; | ||
NSLog(@"[FMDBx] Create initial database file: %@", self.databasePathInDocuments); | ||
} | ||
} | ||
return self; | ||
} | ||
|
||
/** | ||
* Get a FMDatabase instance. | ||
* | ||
* @return FMDatabase instance. | ||
*/ | ||
-(FMDatabase *)database | ||
{ | ||
return [FMDatabase databaseWithPath:self.databasePathInDocuments]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// FMXDatabaseManager.h | ||
// FMDBx | ||
// | ||
// Copyright (c) 2014 KohkiMakimoto. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "FMXDatabaseMigration.h" | ||
#import "FMXDatabaseConfiguration.h" | ||
#import "FMXTableMap.h" | ||
#import "FMXModel.h" | ||
#import "FMXHelpers.h" | ||
#import "FMXQuery.h" | ||
|
||
@class FMXDatabaseMigration; | ||
@class FMXDatabaseConfiguration; | ||
@class FMXQuery; | ||
|
||
@interface FMXDatabaseManager : NSObject | ||
|
||
+ (FMXDatabaseManager *)sharedInstance; | ||
|
||
- (void)registerDatabaseWithName:(NSString *)database | ||
path:(NSString *)databasePath | ||
migration:(FMXDatabaseMigration *)migration; | ||
|
||
- (void)registerDefaultDatabaseWithPath:(NSString *)databasePath | ||
migration:(FMXDatabaseMigration *)migration; | ||
|
||
- (void)destroyDatabase:(NSString *)database; | ||
|
||
- (void)destroyDefaultDatabase; | ||
|
||
- (FMXDatabaseConfiguration *)configuration:(NSString *)database; | ||
|
||
- (FMXDatabaseConfiguration *)defaultConfiguration; | ||
|
||
- (FMDatabase *)database:(NSString *)database; | ||
|
||
- (FMDatabase *)databaseForModel:(Class)modelClass; | ||
|
||
- (FMDatabase *)defaultDatabase; | ||
|
||
- (FMXTableMap *)tableForModel:(Class)modelClass; | ||
|
||
- (FMXQuery *)queryForModel:(Class)modelClass; | ||
|
||
@end |
Oops, something went wrong.