Use SPM for MongoSwift
This commit is contained in:
parent
e40e8d662f
commit
f7310471bf
|
@ -3,7 +3,7 @@
|
||||||
archiveVersion = 1;
|
archiveVersion = 1;
|
||||||
classes = {
|
classes = {
|
||||||
};
|
};
|
||||||
objectVersion = 50;
|
objectVersion = 52;
|
||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
@ -24,27 +24,10 @@
|
||||||
D627CE8924E399F100C39FE5 /* DetailViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D627CE8724E399F100C39FE5 /* DetailViewController.xib */; };
|
D627CE8924E399F100C39FE5 /* DetailViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D627CE8724E399F100C39FE5 /* DetailViewController.xib */; };
|
||||||
D627CE8B24E438EE00C39FE5 /* DatabaseCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = D627CE8A24E438EE00C39FE5 /* DatabaseCollection.swift */; };
|
D627CE8B24E438EE00C39FE5 /* DatabaseCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = D627CE8A24E438EE00C39FE5 /* DatabaseCollection.swift */; };
|
||||||
D627CE8D24E4478800C39FE5 /* JSONPrettyPrinter.swift in Sources */ = {isa = PBXBuildFile; fileRef = D627CE8C24E4478800C39FE5 /* JSONPrettyPrinter.swift */; };
|
D627CE8D24E4478800C39FE5 /* JSONPrettyPrinter.swift in Sources */ = {isa = PBXBuildFile; fileRef = D627CE8C24E4478800C39FE5 /* JSONPrettyPrinter.swift */; };
|
||||||
|
D627CE9024E4A9F100C39FE5 /* MongoSwift in Frameworks */ = {isa = PBXBuildFile; productRef = D627CE8F24E4A9F100C39FE5 /* MongoSwift */; };
|
||||||
D63CDEBE23C837DC0012D658 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D63CDEBD23C837DC0012D658 /* AppDelegate.swift */; };
|
D63CDEBE23C837DC0012D658 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D63CDEBD23C837DC0012D658 /* AppDelegate.swift */; };
|
||||||
D63CDEC023C837DD0012D658 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D63CDEBF23C837DD0012D658 /* Assets.xcassets */; };
|
D63CDEC023C837DD0012D658 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D63CDEBF23C837DD0012D658 /* Assets.xcassets */; };
|
||||||
D63CDEC323C837DD0012D658 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = D63CDEC123C837DD0012D658 /* MainMenu.xib */; };
|
D63CDEC323C837DD0012D658 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = D63CDEC123C837DD0012D658 /* MainMenu.xib */; };
|
||||||
D63CDF1F23C837F10012D658 /* CLibMongoC.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D63CDF1623C837F10012D658 /* CLibMongoC.framework */; };
|
|
||||||
D63CDF2023C837F10012D658 /* CLibMongoC.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D63CDF1623C837F10012D658 /* CLibMongoC.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
|
||||||
D63CDF2123C837F10012D658 /* CNIOAtomics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D63CDF1723C837F10012D658 /* CNIOAtomics.framework */; };
|
|
||||||
D63CDF2223C837F10012D658 /* CNIOAtomics.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D63CDF1723C837F10012D658 /* CNIOAtomics.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
|
||||||
D63CDF2323C837F10012D658 /* CNIODarwin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D63CDF1823C837F10012D658 /* CNIODarwin.framework */; };
|
|
||||||
D63CDF2423C837F10012D658 /* CNIODarwin.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D63CDF1823C837F10012D658 /* CNIODarwin.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
|
||||||
D63CDF2523C837F10012D658 /* CNIOLinux.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D63CDF1923C837F10012D658 /* CNIOLinux.framework */; };
|
|
||||||
D63CDF2623C837F10012D658 /* CNIOLinux.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D63CDF1923C837F10012D658 /* CNIOLinux.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
|
||||||
D63CDF2723C837F10012D658 /* CNIOSHA1.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D63CDF1A23C837F10012D658 /* CNIOSHA1.framework */; };
|
|
||||||
D63CDF2823C837F10012D658 /* CNIOSHA1.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D63CDF1A23C837F10012D658 /* CNIOSHA1.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
|
||||||
D63CDF2923C837F10012D658 /* MongoSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D63CDF1B23C837F10012D658 /* MongoSwift.framework */; };
|
|
||||||
D63CDF2A23C837F10012D658 /* MongoSwift.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D63CDF1B23C837F10012D658 /* MongoSwift.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
|
||||||
D63CDF2B23C837F10012D658 /* MongoSwiftSync.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D63CDF1C23C837F10012D658 /* MongoSwiftSync.framework */; };
|
|
||||||
D63CDF2C23C837F10012D658 /* MongoSwiftSync.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D63CDF1C23C837F10012D658 /* MongoSwiftSync.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
|
||||||
D63CDF2D23C837F10012D658 /* NIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D63CDF1D23C837F10012D658 /* NIO.framework */; };
|
|
||||||
D63CDF2E23C837F10012D658 /* NIO.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D63CDF1D23C837F10012D658 /* NIO.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
|
||||||
D63CDF2F23C837F10012D658 /* NIOConcurrencyHelpers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D63CDF1E23C837F10012D658 /* NIOConcurrencyHelpers.framework */; };
|
|
||||||
D63CDF3023C837F10012D658 /* NIOConcurrencyHelpers.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D63CDF1E23C837F10012D658 /* NIOConcurrencyHelpers.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
|
||||||
D63CDF3723C8381A0012D658 /* Node.swift in Sources */ = {isa = PBXBuildFile; fileRef = D63CDF3323C838190012D658 /* Node.swift */; };
|
D63CDF3723C8381A0012D658 /* Node.swift in Sources */ = {isa = PBXBuildFile; fileRef = D63CDF3323C838190012D658 /* Node.swift */; };
|
||||||
D63CDF3823C8381A0012D658 /* MongoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D63CDF3423C838190012D658 /* MongoController.swift */; };
|
D63CDF3823C8381A0012D658 /* MongoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D63CDF3423C838190012D658 /* MongoController.swift */; };
|
||||||
D63CDF3C23C838470012D658 /* DatabaseWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D63CDF3A23C838470012D658 /* DatabaseWindowController.swift */; };
|
D63CDF3C23C838470012D658 /* DatabaseWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D63CDF3A23C838470012D658 /* DatabaseWindowController.swift */; };
|
||||||
|
@ -61,25 +44,6 @@
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXCopyFilesBuildPhase section */
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
D63CDF3123C837F10012D658 /* Embed Frameworks */ = {
|
|
||||||
isa = PBXCopyFilesBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
dstPath = "";
|
|
||||||
dstSubfolderSpec = 10;
|
|
||||||
files = (
|
|
||||||
D63CDF2823C837F10012D658 /* CNIOSHA1.framework in Embed Frameworks */,
|
|
||||||
D63CDF2623C837F10012D658 /* CNIOLinux.framework in Embed Frameworks */,
|
|
||||||
D63CDF2423C837F10012D658 /* CNIODarwin.framework in Embed Frameworks */,
|
|
||||||
D63CDF2A23C837F10012D658 /* MongoSwift.framework in Embed Frameworks */,
|
|
||||||
D63CDF2223C837F10012D658 /* CNIOAtomics.framework in Embed Frameworks */,
|
|
||||||
D63CDF2023C837F10012D658 /* CLibMongoC.framework in Embed Frameworks */,
|
|
||||||
D63CDF2C23C837F10012D658 /* MongoSwiftSync.framework in Embed Frameworks */,
|
|
||||||
D63CDF3023C837F10012D658 /* NIOConcurrencyHelpers.framework in Embed Frameworks */,
|
|
||||||
D63CDF2E23C837F10012D658 /* NIO.framework in Embed Frameworks */,
|
|
||||||
);
|
|
||||||
name = "Embed Frameworks";
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
D6D13AFF2436C33D00493D97 /* CopyFiles */ = {
|
D6D13AFF2436C33D00493D97 /* CopyFiles */ = {
|
||||||
isa = PBXCopyFilesBuildPhase;
|
isa = PBXCopyFilesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
|
@ -144,15 +108,7 @@
|
||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
D63CDF2723C837F10012D658 /* CNIOSHA1.framework in Frameworks */,
|
D627CE9024E4A9F100C39FE5 /* MongoSwift in Frameworks */,
|
||||||
D63CDF2523C837F10012D658 /* CNIOLinux.framework in Frameworks */,
|
|
||||||
D63CDF2323C837F10012D658 /* CNIODarwin.framework in Frameworks */,
|
|
||||||
D63CDF2923C837F10012D658 /* MongoSwift.framework in Frameworks */,
|
|
||||||
D63CDF2123C837F10012D658 /* CNIOAtomics.framework in Frameworks */,
|
|
||||||
D63CDF1F23C837F10012D658 /* CLibMongoC.framework in Frameworks */,
|
|
||||||
D63CDF2B23C837F10012D658 /* MongoSwiftSync.framework in Frameworks */,
|
|
||||||
D63CDF2F23C837F10012D658 /* NIOConcurrencyHelpers.framework in Frameworks */,
|
|
||||||
D63CDF2D23C837F10012D658 /* NIO.framework in Frameworks */,
|
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@ -291,13 +247,15 @@
|
||||||
D63CDEB623C837DC0012D658 /* Sources */,
|
D63CDEB623C837DC0012D658 /* Sources */,
|
||||||
D63CDEB723C837DC0012D658 /* Frameworks */,
|
D63CDEB723C837DC0012D658 /* Frameworks */,
|
||||||
D63CDEB823C837DC0012D658 /* Resources */,
|
D63CDEB823C837DC0012D658 /* Resources */,
|
||||||
D63CDF3123C837F10012D658 /* Embed Frameworks */,
|
|
||||||
);
|
);
|
||||||
buildRules = (
|
buildRules = (
|
||||||
);
|
);
|
||||||
dependencies = (
|
dependencies = (
|
||||||
);
|
);
|
||||||
name = MongoView;
|
name = MongoView;
|
||||||
|
packageProductDependencies = (
|
||||||
|
D627CE8F24E4A9F100C39FE5 /* MongoSwift */,
|
||||||
|
);
|
||||||
productName = MongoView;
|
productName = MongoView;
|
||||||
productReference = D63CDEBA23C837DC0012D658 /* MongoView.app */;
|
productReference = D63CDEBA23C837DC0012D658 /* MongoView.app */;
|
||||||
productType = "com.apple.product-type.application";
|
productType = "com.apple.product-type.application";
|
||||||
|
@ -346,6 +304,9 @@
|
||||||
Base,
|
Base,
|
||||||
);
|
);
|
||||||
mainGroup = D63CDEB123C837DC0012D658;
|
mainGroup = D63CDEB123C837DC0012D658;
|
||||||
|
packageReferences = (
|
||||||
|
D627CE8E24E4A9F100C39FE5 /* XCRemoteSwiftPackageReference "mongo-swift-driver" */,
|
||||||
|
);
|
||||||
productRefGroup = D63CDEBB23C837DC0012D658 /* Products */;
|
productRefGroup = D63CDEBB23C837DC0012D658 /* Products */;
|
||||||
projectDirPath = "";
|
projectDirPath = "";
|
||||||
projectRoot = "";
|
projectRoot = "";
|
||||||
|
@ -638,6 +599,25 @@
|
||||||
defaultConfigurationName = Release;
|
defaultConfigurationName = Release;
|
||||||
};
|
};
|
||||||
/* End XCConfigurationList section */
|
/* End XCConfigurationList section */
|
||||||
|
|
||||||
|
/* Begin XCRemoteSwiftPackageReference section */
|
||||||
|
D627CE8E24E4A9F100C39FE5 /* XCRemoteSwiftPackageReference "mongo-swift-driver" */ = {
|
||||||
|
isa = XCRemoteSwiftPackageReference;
|
||||||
|
repositoryURL = "https://github.com/mongodb/mongo-swift-driver.git";
|
||||||
|
requirement = {
|
||||||
|
kind = upToNextMinorVersion;
|
||||||
|
minimumVersion = 1.0.1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/* End XCRemoteSwiftPackageReference section */
|
||||||
|
|
||||||
|
/* Begin XCSwiftPackageProductDependency section */
|
||||||
|
D627CE8F24E4A9F100C39FE5 /* MongoSwift */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
package = D627CE8E24E4A9F100C39FE5 /* XCRemoteSwiftPackageReference "mongo-swift-driver" */;
|
||||||
|
productName = MongoSwift;
|
||||||
|
};
|
||||||
|
/* End XCSwiftPackageProductDependency section */
|
||||||
};
|
};
|
||||||
rootObject = D63CDEB223C837DC0012D658 /* Project object */;
|
rootObject = D63CDEB223C837DC0012D658 /* Project object */;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,4 @@
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "container:MongoView.xcodeproj">
|
location = "container:MongoView.xcodeproj">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
<FileRef
|
|
||||||
location = "group:../mongo-swift-driver/MongoSwift.xcodeproj">
|
|
||||||
</FileRef>
|
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
{
|
||||||
|
"object": {
|
||||||
|
"pins": [
|
||||||
|
{
|
||||||
|
"package": "mongo-swift-driver",
|
||||||
|
"repositoryURL": "https://github.com/mongodb/mongo-swift-driver.git",
|
||||||
|
"state": {
|
||||||
|
"branch": null,
|
||||||
|
"revision": "ec67468132743919e90a34a76073afcc4a13355e",
|
||||||
|
"version": "1.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"package": "Nimble",
|
||||||
|
"repositoryURL": "https://github.com/Quick/Nimble.git",
|
||||||
|
"state": {
|
||||||
|
"branch": null,
|
||||||
|
"revision": "2b1809051b4a65c1d7f5233331daa24572cd7fca",
|
||||||
|
"version": "8.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"package": "swift-nio",
|
||||||
|
"repositoryURL": "https://github.com/apple/swift-nio",
|
||||||
|
"state": {
|
||||||
|
"branch": null,
|
||||||
|
"revision": "acf5465b5e7fb9aeda54a34d16fb44c31a399715",
|
||||||
|
"version": "2.20.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"version": 1
|
||||||
|
}
|
|
@ -30,9 +30,9 @@ struct ExtendedJSON {
|
||||||
return context.evaluateScript("JSON.stringify(\(string))")?.toString()
|
return context.evaluateScript("JSON.stringify(\(string))")?.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func fromExtJSON(_ string: String) -> Document? {
|
private static func fromExtJSON(_ string: String) -> BSONDocument? {
|
||||||
do {
|
do {
|
||||||
let doc = try Document(fromJSON: string)
|
let doc = try BSONDocument(fromJSON: string)
|
||||||
return doc
|
return doc
|
||||||
} catch {
|
} catch {
|
||||||
print("Unable to create document from extended JSON: \(error)")
|
print("Unable to create document from extended JSON: \(error)")
|
||||||
|
@ -40,7 +40,7 @@ struct ExtendedJSON {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static func toDocument(_ string: String) -> Document? {
|
static func toDocument(_ string: String) -> BSONDocument? {
|
||||||
guard let normalized = normalize(string),
|
guard let normalized = normalize(string),
|
||||||
let doc = fromExtJSON(normalized) else {
|
let doc = fromExtJSON(normalized) else {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -54,7 +54,7 @@ class MongoController {
|
||||||
return client.db(collection.database)
|
return client.db(collection.database)
|
||||||
}
|
}
|
||||||
|
|
||||||
func collection(_ collection: DatabaseCollection) -> MongoCollection<Document> {
|
func collection(_ collection: DatabaseCollection) -> MongoCollection<BSONDocument> {
|
||||||
return db(for: collection).collection(collection.name)
|
return db(for: collection).collection(collection.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,16 +45,16 @@ class Node: NSObject {
|
||||||
|
|
||||||
if key == nil,
|
if key == nil,
|
||||||
case let .document(doc) = value,
|
case let .document(doc) = value,
|
||||||
case let .objectId(id) = doc["_id"] {
|
case let .objectID(id) = doc["_id"] {
|
||||||
self.key = .objectId(id)
|
self.key = .objectID(id)
|
||||||
} else {
|
} else {
|
||||||
self.key = key
|
self.key = key
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
convenience init(document: Document) {
|
convenience init(document: BSONDocument) {
|
||||||
if case let .objectId(id) = document["_id"] {
|
if case let .objectID(id) = document["_id"] {
|
||||||
self.init(key: .objectId(id), value: .document(document))
|
self.init(key: .objectID(id), value: .document(document))
|
||||||
} else {
|
} else {
|
||||||
self.init(key: nil, value: .document(document))
|
self.init(key: nil, value: .document(document))
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ extension Node {
|
||||||
enum Key: Equatable, Hashable {
|
enum Key: Equatable, Hashable {
|
||||||
case index(Int)
|
case index(Int)
|
||||||
case name(String)
|
case name(String)
|
||||||
case objectId(ObjectId)
|
case objectID(BSONObjectID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ extension Node {
|
||||||
return index.description
|
return index.description
|
||||||
case let .name(name):
|
case let .name(name):
|
||||||
return name
|
return name
|
||||||
case let .objectId(id):
|
case let .objectID(id):
|
||||||
return id.description
|
return id.description
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,9 +113,7 @@ extension Node {
|
||||||
case let .array(array):
|
case let .array(array):
|
||||||
return "(\(array.count) element\(array.count == 1 ? "" : "s"))"
|
return "(\(array.count) element\(array.count == 1 ? "" : "s"))"
|
||||||
case let .binary(value):
|
case let .binary(value):
|
||||||
switch Binary.Subtype(rawValue: value.subtype) {
|
switch value.subtype {
|
||||||
case nil:
|
|
||||||
return "(unknown binary data)"
|
|
||||||
case .generic:
|
case .generic:
|
||||||
return "(generic binary data)"
|
return "(generic binary data)"
|
||||||
case .function:
|
case .function:
|
||||||
|
@ -125,15 +123,15 @@ extension Node {
|
||||||
case .uuidDeprecated:
|
case .uuidDeprecated:
|
||||||
fallthrough
|
fallthrough
|
||||||
case .uuid:
|
case .uuid:
|
||||||
return try! UUID(from: value).description
|
return try! value.toUUID().description
|
||||||
case .md5:
|
case .md5:
|
||||||
return "(MD5 binary data)"
|
return "(MD5 binary data)"
|
||||||
case .userDefined:
|
default:
|
||||||
return "(user defined binary data)"
|
return "(unknown binary data))"
|
||||||
}
|
}
|
||||||
case .undefined:
|
case .undefined:
|
||||||
return "undefined"
|
return "undefined"
|
||||||
case let .objectId(value):
|
case let .objectID(value):
|
||||||
return value.description
|
return value.description
|
||||||
case let .bool(value):
|
case let .bool(value):
|
||||||
return value.description
|
return value.description
|
||||||
|
@ -142,7 +140,7 @@ extension Node {
|
||||||
case .null:
|
case .null:
|
||||||
return "null"
|
return "null"
|
||||||
case let .regex(value):
|
case let .regex(value):
|
||||||
return try! NSRegularExpression(from: value).description
|
return value.pattern
|
||||||
case let .dbPointer(value):
|
case let .dbPointer(value):
|
||||||
return "\(value.ref)(\(value.id))"
|
return "\(value.ref)(\(value.id))"
|
||||||
case let .symbol(value):
|
case let .symbol(value):
|
||||||
|
@ -178,9 +176,7 @@ extension Node {
|
||||||
case .array(_):
|
case .array(_):
|
||||||
return "Array"
|
return "Array"
|
||||||
case let .binary(value):
|
case let .binary(value):
|
||||||
switch Binary.Subtype(rawValue: value.subtype) {
|
switch value.subtype {
|
||||||
case nil:
|
|
||||||
return "Unknown binary data"
|
|
||||||
case .generic:
|
case .generic:
|
||||||
return "Generic binary data"
|
return "Generic binary data"
|
||||||
case .function:
|
case .function:
|
||||||
|
@ -193,12 +189,12 @@ extension Node {
|
||||||
return "UUID"
|
return "UUID"
|
||||||
case .md5:
|
case .md5:
|
||||||
return "MD5 hash"
|
return "MD5 hash"
|
||||||
case .userDefined:
|
default:
|
||||||
return "User defined binary data"
|
return "Unknown binary data"
|
||||||
}
|
}
|
||||||
case .undefined:
|
case .undefined:
|
||||||
return "Undefined"
|
return "Undefined"
|
||||||
case .objectId(_):
|
case .objectID(_):
|
||||||
return "ObjectId"
|
return "ObjectId"
|
||||||
case .bool(_):
|
case .bool(_):
|
||||||
return "Bool"
|
return "Bool"
|
||||||
|
|
|
@ -13,7 +13,7 @@ class EditDocumentViewController: NSViewController {
|
||||||
|
|
||||||
private(set) var mongoController: MongoController!
|
private(set) var mongoController: MongoController!
|
||||||
private(set) var collection: DatabaseCollection!
|
private(set) var collection: DatabaseCollection!
|
||||||
private(set) var document: Document!
|
private(set) var document: BSONDocument!
|
||||||
|
|
||||||
var documentEdited: (() -> Void)?
|
var documentEdited: (() -> Void)?
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class EditDocumentViewController: NSViewController {
|
||||||
@IBOutlet weak var cancelButton: NSButton!
|
@IBOutlet weak var cancelButton: NSButton!
|
||||||
@IBOutlet weak var validateButton: NSButton!
|
@IBOutlet weak var validateButton: NSButton!
|
||||||
|
|
||||||
init(mongoController: MongoController, collection: DatabaseCollection, document: Document) {
|
init(mongoController: MongoController, collection: DatabaseCollection, document: BSONDocument) {
|
||||||
self.mongoController = mongoController
|
self.mongoController = mongoController
|
||||||
self.collection = collection
|
self.collection = collection
|
||||||
self.document = document
|
self.document = document
|
||||||
|
@ -38,7 +38,8 @@ class EditDocumentViewController: NSViewController {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
let printer = JSONPrettyPrinter(options: .convertMongoObjects)
|
let printer = JSONPrettyPrinter(options: .convertMongoObjects)
|
||||||
editorTextView.string = (try? printer.prettify(document.extendedJSON)) ?? document.extendedJSON
|
let extended = document.toExtendedJSONString()
|
||||||
|
editorTextView.string = (try? printer.prettify(extended)) ?? extended
|
||||||
|
|
||||||
editorTextView.isAutomaticQuoteSubstitutionEnabled = false
|
editorTextView.isAutomaticQuoteSubstitutionEnabled = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
import Cocoa
|
import Cocoa
|
||||||
import MongoSwift
|
import MongoSwift
|
||||||
|
import NIO
|
||||||
|
|
||||||
class QueryViewController: NSViewController {
|
class QueryViewController: NSViewController {
|
||||||
|
|
||||||
|
@ -70,7 +71,7 @@ class QueryViewController: NSViewController {
|
||||||
|
|
||||||
func refresh(reload: Bool = true) {
|
func refresh(reload: Bool = true) {
|
||||||
let filterText = filterTextView.string.trimmingCharacters(in: .whitespacesAndNewlines)
|
let filterText = filterTextView.string.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
let filter: Document
|
let filter: BSONDocument
|
||||||
if !filterText.isEmpty,
|
if !filterText.isEmpty,
|
||||||
let doc = ExtendedJSON.toDocument(filterText) {
|
let doc = ExtendedJSON.toDocument(filterText) {
|
||||||
filter = doc
|
filter = doc
|
||||||
|
@ -78,17 +79,25 @@ class QueryViewController: NSViewController {
|
||||||
filter = [:]
|
filter = [:]
|
||||||
}
|
}
|
||||||
|
|
||||||
let documents = try! mongoController.collection(collection).find(filter).all()
|
mongoController.statusManager.set("Querying \(collection)...", for: .query, override: true)
|
||||||
rootNodes = documents.map { Node(document: $0) }
|
|
||||||
|
|
||||||
title = "\(self.collection.database).\(self.collection.name)"
|
|
||||||
documentCountLabel.stringValue = "\(documents.count) document\(documents.count == 1 ? "" : "s")"
|
|
||||||
|
|
||||||
if reload {
|
let collection = mongoController.collection(self.collection)
|
||||||
outlineView.reloadData()
|
collection.find(filter).flatMap { (cursor: MongoCursor) -> EventLoopFuture<[BSONDocument]> in
|
||||||
|
return cursor.toArray()
|
||||||
|
}.whenSuccess { (documents) in
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.rootNodes = documents.map { Node(document: $0) }
|
||||||
|
|
||||||
|
self.title = "\(self.collection.database).\(self.collection.name)"
|
||||||
|
self.documentCountLabel.stringValue = "\(documents.count) document\(documents.count == 1 ? "" : "s")"
|
||||||
|
|
||||||
|
if reload {
|
||||||
|
self.outlineView.reloadData()
|
||||||
|
}
|
||||||
|
|
||||||
|
self.mongoController.statusManager.set("Queried \(collection)", for: .query, override: true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mongoController.statusManager.set("Queried \(collection)", for: .query, override: true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteRootNode(_ node: Node) {
|
func deleteRootNode(_ node: Node) {
|
||||||
|
@ -97,8 +106,8 @@ class QueryViewController: NSViewController {
|
||||||
alert.alertStyle = .warning
|
alert.alertStyle = .warning
|
||||||
alert.messageText = "Confirm deletion"
|
alert.messageText = "Confirm deletion"
|
||||||
alert.informativeText = "Are you sure you want to delete the document"
|
alert.informativeText = "Are you sure you want to delete the document"
|
||||||
let id: ObjectId?
|
let id: BSONObjectID?
|
||||||
if case let .objectId(docId) = doc["_id"] {
|
if case let .objectID(docId) = doc["_id"] {
|
||||||
id = docId
|
id = docId
|
||||||
alert.informativeText += " with id \(docId)"
|
alert.informativeText += " with id \(docId)"
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -13,11 +13,11 @@ class EditDocumentWindowController: NSWindowController {
|
||||||
|
|
||||||
private(set) var mongoController: MongoController!
|
private(set) var mongoController: MongoController!
|
||||||
private(set) var collection: DatabaseCollection!
|
private(set) var collection: DatabaseCollection!
|
||||||
private(set) var mongoDocument: Document!
|
private(set) var mongoDocument: BSONDocument!
|
||||||
|
|
||||||
var documentEdited: (() -> Void)?
|
var documentEdited: (() -> Void)?
|
||||||
|
|
||||||
convenience init(mongoController: MongoController, collection: DatabaseCollection, document: Document) {
|
convenience init(mongoController: MongoController, collection: DatabaseCollection, document: BSONDocument) {
|
||||||
self.init(windowNibName: "EditDocumentWindowController")
|
self.init(windowNibName: "EditDocumentWindowController")
|
||||||
|
|
||||||
self.mongoController = mongoController
|
self.mongoController = mongoController
|
||||||
|
|
Loading…
Reference in New Issue