Skip to content

Commit

Permalink
mongo-swift-driver 0.1.3 (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriomazzeo authored Jun 7, 2019
1 parent 9fa66b5 commit ecfb34f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 87 deletions.
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

0 comments on commit ecfb34f

Please sign in to comment.