Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mongo-swift-driver 0.1.3 #13

Merged
merged 1 commit into from
Jun 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ DEPENDENCIES
bundler

BUNDLED WITH
1.17.2
2.0.1
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/vapor/core.git", .upToNextMajor(from: "3.8.1")),
.package(url: "https://github.com/vapor/fluent.git", .upToNextMajor(from: "3.2.0")),
.package(url: "https://github.com/mongodb/mongo-swift-driver.git", .upToNextMinor(from: "0.1.0"))
.package(url: "https://github.com/mongodb/mongo-swift-driver.git", .upToNextMinor(from: "0.1.3"))
],
targets: [
.target(name: "FluentMongo", dependencies: ["Async", "Fluent", "MongoSwift"]),
Expand Down
1 change: 0 additions & 1 deletion Sources/FluentMongo/FluentMongoProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public final class FluentMongoProvider: Provider {
public init() {}

public func register(_ services: inout Services) throws {
MongoSwift.initialize()
try services.register(FluentProvider())
try services.register(DatabaseKitProvider())
services.register(MongoDatabaseConfig.self)
Expand Down
92 changes: 8 additions & 84 deletions Sources/FluentMongo/IndexBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,108 +49,32 @@ extension IndexBuilder {
}

public func background(_ value: Bool) -> IndexBuilder<T> {
let previous = self.index.options
let options = IndexOptions(
background: value,
expireAfter: previous?.expireAfter,
name: previous?.name,
sparse: previous?.sparse,
storageEngine: previous?.storageEngine,
unique: previous?.unique,
version: previous?.version,
defaultLanguage: previous?.defaultLanguage,
languageOverride: previous?.defaultLanguage,
textVersion: previous?.textVersion,
weights: previous?.weights,
sphereVersion: previous?.sphereVersion,
bits: previous?.bits,
max: previous?.max,
min: previous?.min,
bucketSize: previous?.bucketSize,
partialFilterExpression: previous?.partialFilterExpression,
collation: previous?.collation
)
var options = self.index.options ?? IndexOptions()
options.background = value
self.index = IndexModel(keys: self.index.keys, options: options)

return self
}

public func expireAfter(_ value: Int32) -> IndexBuilder<T> {
let previous = self.index.options
let options = IndexOptions(
background: previous?.background,
expireAfter: value,
name: previous?.name,
sparse: previous?.sparse,
storageEngine: previous?.storageEngine,
unique: previous?.unique,
version: previous?.version,
defaultLanguage: previous?.defaultLanguage,
languageOverride: previous?.defaultLanguage,
textVersion: previous?.textVersion,
weights: previous?.weights,
sphereVersion: previous?.sphereVersion,
bits: previous?.bits,
max: previous?.max,
min: previous?.min,
bucketSize: previous?.bucketSize,
partialFilterExpression: previous?.partialFilterExpression,
collation: previous?.collation
)
var options = self.index.options ?? IndexOptions()
options.expireAfterSeconds = value
self.index = IndexModel(keys: self.index.keys, options: options)

return self
}

public func name(_ value: String) -> IndexBuilder<T> {
let previous = self.index.options
let options = IndexOptions(
background: previous?.background,
expireAfter: previous?.expireAfter,
name: value,
sparse: previous?.sparse,
storageEngine: previous?.storageEngine,
unique: previous?.unique,
version: previous?.version,
defaultLanguage: previous?.defaultLanguage,
languageOverride: previous?.defaultLanguage,
textVersion: previous?.textVersion,
weights: previous?.weights,
sphereVersion: previous?.sphereVersion,
bits: previous?.bits,
max: previous?.max,
min: previous?.min,
bucketSize: previous?.bucketSize,
partialFilterExpression: previous?.partialFilterExpression,
collation: previous?.collation
)
var options = self.index.options ?? IndexOptions()
options.name = value
self.index = IndexModel(keys: self.index.keys, options: options)

return self
}

public func unique(_ value: Bool) -> IndexBuilder<T> {
let previous = self.index.options
let options = IndexOptions(
background: previous?.background,
expireAfter: previous?.expireAfter,
name: previous?.name,
sparse: previous?.sparse,
storageEngine: previous?.storageEngine,
unique: value,
version: previous?.version,
defaultLanguage: previous?.defaultLanguage,
languageOverride: previous?.defaultLanguage,
textVersion: previous?.textVersion,
weights: previous?.weights,
sphereVersion: previous?.sphereVersion,
bits: previous?.bits,
max: previous?.max,
min: previous?.min,
bucketSize: previous?.bucketSize,
partialFilterExpression: previous?.partialFilterExpression,
collation: previous?.collation
)
var options = self.index.options ?? IndexOptions()
options.unique = value
self.index = IndexModel(keys: self.index.keys, options: options)

return self
Expand Down