samedi 8 août 2015

Errors on using foreign keys in SQLite.swift

I am attempting to create a table that uses foreign keys. According to the documentation, the syntax for this should be:

t.foreignKey(user_id, on: users[id], delete: .SetNull)

However, when I'm using a syntax like:

t.foreignKey(charWeaponID, on: Weapon.Weapons[id], delete: .SetNull)

It tells me I have an error: 'Weapon.Type' does not have a member named 'Weapons'

I have my Weapons table created in a struct called Weapon. If I were to try and use:

t.foreignKey(charWeaponID, on: Weapons[id], delete: .SetNull)

then it just returns an error "Use of unresolved identifier 'Weapons'".

So what is the correct syntax in this instance?

Aucun commentaire:

Enregistrer un commentaire