CapDatabase

class CapDatabase

A utility class to make Firebase communication and actions easy

  • Empty init

    Declaration

    Swift

    init()
  • Create an instance of CapDatabase with userID and get/set user information

    Declaration

    Swift

    init(userID: String)

    Parameters

    userID

    unique user ID

  • Create an instance of CapDatabase with a CapUser instance

    Declaration

    Swift

    init(user: CapUser)

    Parameters

    user

    a CapUser user

  • Setup the initial user and user limit

    Declaration

    Swift

    func setupUser()

    Return Value

    Void

  • Update the user’s photo limit

    Declaration

    Swift

    func photoLimit(callback: @escaping (Int)->())

    Parameters

    callback

    a callback function to return the current photoLimit

    Return Value

    Void

  • Update/Replace the user’s name

    Declaration

    Swift

    func update(name: String)

    Parameters

    name

    the name to be updated/replaced

    Return Value

    Void

  • Accepts an image data to be uploaded and return its URL

    Declaration

    Swift

    func uploadImage(imageData: Data, success: @escaping (_ url:String)->())

    Parameters

    imageData

    the image data to be uploaded

    success

    a callback function with url

    Return Value

    Void

  • Add a new image with text and name to Firebase

    Declaration

    Swift

    func addNew(image data: Data, with text: String, with name: String, callback: @escaping ()->())

    Parameters

    data

    the image data to be uploaded

    text

    the text of the image (landmark text taken from WikiPedia).

    name

    the name of the image (landmark name)

    callback

    a callback for UI.

    Return Value

    Void

  • Get all user images from the database

    Declaration

    Swift

    func getImages(_ callback: @escaping (UserImage)->())

    Parameters

    callback

    a callback function that returns the UserImage object for presentation

    Return Value

    Void

  • Get the user name

    Declaration

    Swift

    func getName(_ callback: @escaping (String)->())

    Parameters

    callback

    a a callback function that returns the name of the user

    Return Value

    Void

  • Delete image from the database

    Declaration

    Swift

    func deleteUserImage(userImage: UserImage)

    Parameters

    userImage

    the UserImage object to be deleted

    Return Value

    Void