Class: Folder

Folder(library, row) → {Folder}

The Folder class contains Albums and sub-Folders. It's basically what you see in the sidebar of your Photos app: a folder structure of albums.

Read from the database RKFolder.

Constructor

new Folder(library, row) → {Folder}

Create a new Folder class.

Parameters:
Name Type Description
library PhotosLibrary

An instance of PhotosLibrary used for album fetching.

row Object

A database row from RKFolder.

Source:
Returns:

The generated Folder instance.

Type
Folder

Members

albums :Array.<Album>

The Albums located in this Folder.

Will only be initialized after initFolder() is called!

Type:
Source:

cloudId :string

The cloud ID of the Folder. (database field: cloudIdentifier).

Type:
  • string
Source:

created :Date

The date the Folder was created. (database field: createDate).

The database value is converted from a Apple Core Data date to a Javascript Date object.

Type:
  • Date
Source:

folders :Array.<Folder>

The sub-Folders located in this Folder.

Will only be initialized after initFolder() is called!

Type:
Source:

id :int

The ID of the Folder in the database (database field: modelId).

Type:
  • int
Source:

library :PhotosLibrary

The library used for media fetching.

Type:
  • PhotosLibrary
Source:

magic :Bool

A Folder is magic if it is generated by Apple Photos and not by the user (e.g. Favorites).

Type:
  • Bool
Source:

name :string

The name of the Folder. (database field: name).

Type:
  • string
Source:

parentFolderUuid :string

The uuid of the parent Folder the Folder is in. (database field: folderUuid).

Type:
  • string
Source:

synced :Bool

Wether or not the folder has been synced to iCloud. (database field: hasBeenSynced).

Type:
  • Bool
Source:

uuid :string

The uuid of the Folder in the database (database field: uuid).

Type:
  • string
Source:

Methods

countAlbums() → {int}

Count all the albums in this folder.

This will recursively call the same function on all subfolders to get a true total.

Source:
Returns:

Total amount of Albums in the Folder (including subfolders).

Type
int

(async) initFolder()

Initialize this folder and load Albums and sub-Folders.

This method needs to be called in order for the albums and folders properties to be populated.

Source:

toJSON() → {Object}

Prepare the Folder for JSON serialization.

This function is needed to exclude the library property from JSON serialization.

Source:
Returns:

The filtered object.

Type
Object