2023-07-05 01:14:44 +02:00
|
|
|
const uuidv4 = require("uuid").v4
|
2021-11-16 03:09:42 +01:00
|
|
|
|
2021-10-05 05:11:42 +02:00
|
|
|
class Folder {
|
|
|
|
constructor(folder = null) {
|
|
|
|
this.id = null
|
|
|
|
this.fullPath = null
|
|
|
|
this.libraryId = null
|
|
|
|
this.addedAt = null
|
|
|
|
|
|
|
|
if (folder) {
|
|
|
|
this.construct(folder)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
construct(folder) {
|
|
|
|
this.id = folder.id
|
|
|
|
this.fullPath = folder.fullPath
|
|
|
|
this.libraryId = folder.libraryId
|
|
|
|
this.addedAt = folder.addedAt
|
|
|
|
}
|
|
|
|
|
|
|
|
toJSON() {
|
|
|
|
return {
|
|
|
|
id: this.id,
|
|
|
|
fullPath: this.fullPath,
|
|
|
|
libraryId: this.libraryId,
|
|
|
|
addedAt: this.addedAt
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setData(data) {
|
2023-07-05 01:14:44 +02:00
|
|
|
this.id = data.id || uuidv4()
|
2021-10-05 05:11:42 +02:00
|
|
|
this.fullPath = data.fullPath
|
|
|
|
this.libraryId = data.libraryId
|
|
|
|
this.addedAt = Date.now()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = Folder
|