// SAVE
let user: User = User()
user.name = "1amageek"
user.save()
// GET
User.get("user_id") { user, error in
if let error = error {
print(error)
return
}
print(user)
// UPDATE
user?.name = "Norikazu Muramoto"
user?.update()
}
@objcMembers
class User: Object {
dynamic var name: String?
}
Slide 44
Slide 44 text
@objcMembers
class User: Object, UserProtocol {
dynamic var name: String?
let groups: ReferenceCollection = []
}
@objcMembers
class Group: Object, UserProtocol {
dynamic var name: String?
let users: ReferenceCollection = []
}
Slide 45
Slide 45 text
@objcMembers
class User: Object, UserProtocol {
dynamic var name: String?
let groups: ReferenceCollection = []
}
@objcMembers
class Group: Object, UserProtocol {
dynamic var name: String?
let users: ReferenceCollection = []
}
Slide 46
Slide 46 text
let user0: User = User()
let user1: User = User()
let group: Group = Group()
// ૬ޓࢀর͢Δ
user0.groups.insert(group)
user1.groups.insert(group)
group.users.insert(user0)
group.users.insert(user1)
// อଘ͢Δ
group.save()
Slide 47
Slide 47 text
Secure
Document
Document
App
Firebase
Slide 48
Slide 48 text
service cloud.firestore {
match /databases/{database}/documents {
// user
match /user/{userID} {
allow read: if request.auth != null;
allow write: if request.auth.uid == userID;
}
}
}
Slide 49
Slide 49 text
service cloud.firestore {
match /databases/{database}/documents {
// user
match /user/{userID} {
allow read: if request.auth != null;
allow write: if request.auth.uid == userID;
}
}
}