-
Notifications
You must be signed in to change notification settings - Fork 19
/
Model.jl
38 lines (30 loc) · 958 Bytes
/
Model.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module Model
import Base: ==
using StructTypes
export Album, User
mutable struct Album
id::Int64 # service-managed
userid::Int64 # service-managed
name::String
artist::String
year::Int64
timespicked::Int64 # service-managed
songs::Vector{String}
end
==(x::Album, y::Album) = x.id == y.id
Album() = Album(0, 0, "", "", 0, 0, String[])
Album(name, artist, year, songs) = Album(0, 0, name, artist, year, 0, songs)
StructTypes.StructType(::Type{Album}) = StructTypes.Mutable()
StructTypes.idproperty(::Type{Album}) = :id
mutable struct User
id::Int64 # service-managed
username::String
password::String
end
==(x::User, y::User) = x.id == y.id
User() = User(0, "", "")
User(username::String, password::String) = User(0, username, password)
User(id::Int64, username::String) = User(id, username, "")
StructTypes.StructType(::Type{User}) = StructTypes.Mutable()
StructTypes.idproperty(::Type{User}) = :id
end # module