 //
 //  Attachment+Database.swift
-//  Database
+//  NetNewsWire
 //
 //  Created by Brent Simmons on 7/4/17.
 //  Copyright © 2017 Ranchero Software. All rights reserved.

extension Attachment {

	init?(row: FMResultSet) {

		guard let url = row.string(forColumn: DatabaseKey.url) else {
			return nil
		}

		let attachmentID = row.string(forColumn: DatabaseKey.attachmentID)
		let mimeType = row.string(forColumn: DatabaseKey.mimeType)
		let title = row.string(forColumn: DatabaseKey.title)
		let sizeInBytes = row.optionalIntForColumn(DatabaseKey.sizeInBytes)
		let durationInSeconds = row.optionalIntForColumn(DatabaseKey.durationInSeconds)

		self.init(attachmentID: attachmentID, url: url, mimeType: mimeType, title: title, sizeInBytes: sizeInBytes, durationInSeconds: durationInSeconds)
	}

	init?(parsedAttachment: ParsedAttachment) {
		self.init(attachmentID: nil, url: parsedAttachment.url, mimeType: parsedAttachment.mimeType, title: parsedAttachment.title, sizeInBytes: parsedAttachment.sizeInBytes, durationInSeconds: parsedAttachment.durationInSeconds)
	}

	static func attachmentsWithParsedAttachments(_ parsedAttachments: Set<ParsedAttachment>?) -> Set<Attachment>? {
		guard let parsedAttachments = parsedAttachments else {
			return nil
		}
