Skip to content

Commit 37c84c8

Browse files
committed
initial
0 parents  commit 37c84c8

11 files changed

Lines changed: 550 additions & 0 deletions

File tree

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
.build
3+
Packages
4+
*.xcodeproj
5+
xcuserdata
6+
DerivedData
7+
.swiftpm
8+
*.xctestplan

.swift-format

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"fileScopedDeclarationPrivacy" : {
3+
"accessLevel" : "private"
4+
},
5+
"indentation" : {
6+
"spaces" : 4
7+
},
8+
"indentConditionalCompilationBlocks" : false,
9+
"indentSwitchCaseLabels" : false,
10+
"lineBreakAroundMultilineExpressionChainComponents" : true,
11+
"lineBreakBeforeControlFlowKeywords" : true,
12+
"lineBreakBeforeEachArgument" : true,
13+
"lineBreakBeforeEachGenericRequirement" : true,
14+
"lineLength" : 80,
15+
"maximumBlankLines" : 1,
16+
"prioritizeKeepingFunctionOutputTogether" : false,
17+
"respectsExistingLineBreaks" : true,
18+
"rules" : {
19+
"AllPublicDeclarationsHaveDocumentation" : true,
20+
"AlwaysUseLowerCamelCase" : false,
21+
"AmbiguousTrailingClosureOverload" : true,
22+
"BeginDocumentationCommentWithOneLineSummary" : false,
23+
"DoNotUseSemicolons" : true,
24+
"DontRepeatTypeInStaticProperties" : false,
25+
"FileScopedDeclarationPrivacy" : true,
26+
"FullyIndirectEnum" : true,
27+
"GroupNumericLiterals" : true,
28+
"IdentifiersMustBeASCII" : true,
29+
"NeverForceUnwrap" : false,
30+
"NeverUseForceTry" : false,
31+
"NeverUseImplicitlyUnwrappedOptionals" : false,
32+
"NoAccessLevelOnExtensionDeclaration" : false,
33+
"NoAssignmentInExpressions" : true,
34+
"NoBlockComments" : true,
35+
"NoCasesWithOnlyFallthrough" : true,
36+
"NoEmptyTrailingClosureParentheses" : true,
37+
"NoLabelsInCasePatterns" : false,
38+
"NoLeadingUnderscores" : false,
39+
"NoParensAroundConditions" : true,
40+
"NoVoidReturnOnFunctionSignature" : true,
41+
"OneCasePerLine" : true,
42+
"OneVariableDeclarationPerLine" : true,
43+
"OnlyOneTrailingClosureArgument" : true,
44+
"OrderedImports" : false,
45+
"ReturnVoidInsteadOfEmptyTuple" : true,
46+
"UseEarlyExits" : false,
47+
"UseLetInEveryBoundCaseVariable" : false,
48+
"UseShorthandTypeNames" : true,
49+
"UseSingleLinePropertyGetter" : false,
50+
"UseSynthesizedInitializer" : true,
51+
"UseTripleSlashForDocumentationComments" : true,
52+
"UseWhereClausesInForLoops" : false,
53+
"ValidateDocumentationComments" : true
54+
},
55+
"spacesAroundRangeFormationOperators" : false,
56+
"tabWidth" : 4,
57+
"version" : 1
58+
}

LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
MIT License
2+
3+
Copyright (c) 2018-2022 Tibor Bödecs
4+
Copyright (c) 2022-2023 Binary Birds Ltd.
5+
6+
Permission is hereby granted, free of charge, to any person
7+
obtaining a copy of this software and associated documentation
8+
files (the "Software"), to deal in the Software without
9+
restriction, including without limitation the rights to use,
10+
copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the
12+
Software is furnished to do so, subject to the following
13+
conditions:
14+
15+
The above copyright notice and this permission notice shall be
16+
included in all copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25+
OTHER DEALINGS IN THE SOFTWARE.

Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
build:
2+
swift build
3+
4+
release:
5+
swift build -c release
6+
7+
test:
8+
swift test --parallel
9+
10+
test-with-coverage:
11+
swift test --parallel --enable-code-coverage
12+
13+
clean:
14+
rm -rf .build
15+
16+
format:
17+
swift-format -i -r ./Sources && swift-format -i -r ./Tests

Package.resolved

Lines changed: 149 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// swift-tools-version:5.9
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "feather-relational-database-driver-postgres",
6+
platforms: [
7+
.macOS(.v13),
8+
.iOS(.v16),
9+
.tvOS(.v16),
10+
.watchOS(.v9),
11+
.visionOS(.v1),
12+
],
13+
products: [
14+
.library(name: "FeatherRelationalDatabaseDriverPostgres", targets: ["FeatherRelationalDatabaseDriverPostgres"]),
15+
],
16+
dependencies: [
17+
.package(url: "https://github.com/feather-framework/feather-relational-database", .upToNextMinor(from: "0.1.1")),
18+
.package(url: "https://github.com/vapor/postgres-kit", from: "2.12.0"),
19+
],
20+
targets: [
21+
.target(
22+
name: "FeatherRelationalDatabaseDriverPostgres",
23+
dependencies: [
24+
.product(name: "FeatherRelationalDatabase", package: "feather-relational-database"),
25+
.product(name: "PostgresKit", package: "postgres-kit"),
26+
]
27+
),
28+
.testTarget(
29+
name: "FeatherRelationalDatabaseDriverPostgresTests",
30+
dependencies: [
31+
.target(name: "FeatherRelationalDatabaseDriverPostgres"),
32+
]
33+
),
34+
]
35+
)

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Feather SQL Database
2+
3+
An abstract sql-database service for Feather CMS.
4+
5+
## Getting started
6+
7+
⚠️ This repository is a work in progress, things can break until it reaches v1.0.0.
8+
9+
Use at your own risk.
10+
11+
### Adding the dependency
12+
13+
To add a dependency on the package, declare it in your `Package.swift`:
14+
15+
```swift
16+
.package(url: "https://github.com/feather-framework/feather-sql-database.git", .upToNextMinor(from: "0.1.0")),
17+
```
18+
19+
and to your application target, add `FeatherSQLDatabase` to your dependencies:
20+
21+
```swift
22+
.product(name: "FeatherSQLDatabase", package: "feather-sql-database")
23+
```
24+
25+
Example `Package.swift` file with `FeatherSQLDatabase` as a dependency:
26+
27+
```swift
28+
// swift-tools-version:5.9
29+
import PackageDescription
30+
31+
let package = Package(
32+
name: "my-application",
33+
dependencies: [
34+
.package(url: "https://github.com/feather-framework/feather-sql-database.git", .upToNextMinor(from: "0.1.0")),
35+
],
36+
targets: [
37+
.target(name: "MyApplication", dependencies: [
38+
.product(name: "FeatherSQLDatabase", package: "feather-sql-database")
39+
]),
40+
.testTarget(name: "MyApplicationTests", dependencies: [
41+
.target(name: "MyApplication"),
42+
]),
43+
]
44+
)
45+
```
46+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//
2+
// File 2.swift
3+
//
4+
//
5+
// Created by Tibor Bodecs on 03/12/2023.
6+
//
7+
8+
import FeatherService
9+
import FeatherRelationalDatabase
10+
import SQLKit
11+
import PostgresKit
12+
@preconcurrency import AsyncKit
13+
14+
@dynamicMemberLookup
15+
struct PostgresRelationalDatabaseService: RelationalDatabaseService {
16+
17+
public let config: ServiceConfig
18+
let pool: EventLoopGroupConnectionPool<PostgresConnectionSource>
19+
20+
subscript<T>(
21+
dynamicMember keyPath: KeyPath<PostgresRelationalDatabaseServiceContext, T>
22+
) -> T {
23+
let context = config.context as! PostgresRelationalDatabaseServiceContext
24+
return context[keyPath: keyPath]
25+
}
26+
27+
init(
28+
config: ServiceConfig,
29+
pool: EventLoopGroupConnectionPool<PostgresConnectionSource>
30+
) {
31+
self.config = config
32+
self.pool = pool
33+
}
34+
35+
public func connection() async throws -> SQLKit.SQLDatabase {
36+
pool.database(logger: self.logger).sql()
37+
}
38+
39+
}

0 commit comments

Comments
 (0)