import thinky from './thinky';
var thinkyType = thinky.type;

export var Person = thinky.createModel("person", {
  id: thinkyType.string().options({enforce_missing: false}),
  email: thinkyType.string()
});

export var Field = thinky.createModel("field", {
  id: thinkyType.string().options({enforce_missing: false}),
  label: thinkyType.string(),
  type: thinkyType.string().enum(['NUMBER', 'STRING', 'BOOLEAN']),
  choices: []
})

export var Note = thinky.createModel("note", {
  id: thinkyType.string().options({enforce_missing: false}),
  about: {
    table: thinkyType.string(),
    id: thinkyType.string()
  },
  fieldId: thinkyType.string(),
  value: thinkyType.any(),
  source: {
    table: thinkyType.string(),
    id: thinkyType.string()
  }
})

// An invitation gets sent to volunteers and they can pick one group call.
export var GroupCallInvitation = thinky.createModel("group_call_invitation", {
  id: thinkyType.string().options({enforce_missing: false}),
  topic: thinkyType.string()
})

export var GroupCall = thinky.createModel("group_call", {
  id: thinkyType.string().options({enforce_missing: false}),
  scheduledTime: thinkyType.date(),
  maxSignups: thinkyType.number(),
  groupCallInvitationId: thinkyType.string(),
  signups: [{
    personId: thinkyType.string(),
    attended: thinkyType.boolean(),
    role: thinkyType.string().enum(['HOST', 'NOTETAKER', 'PARTICIPANT'])
  }]
})

Note.belongsTo(Field, "field", "fieldId", "id")
GroupCallInvitation.hasMany(GroupCall, "groupCalls", "id", "groupCallInvitationId")
GroupCall.belongsTo(GroupCallInvitation, "groupCallInvitation", "groupCallInvitationId", "id")
@@ -753,109 +753,250 @@
 %7D)%0A%0A
-// An invitation gets sent to volunteers and they can pick one group call.%0Aexport var GroupCallInvita
+export var Survey = thinky.createModel(%22survey%22, %7B%0A  id: thinkyType.string().options(%7Benforce_missing: false%7D),%0A  data: %5B%7B%0A    table: thinkyType.string(),%0A    id: thinkyType.string()%0A  %7D%5D,%0A  link: thinkyType.string()%0A%7D)%0A%0Aexport var SurveyQues
 tion
@@ -1022,25 +1022,19 @@
 el(%22
-group_call_invita
+survey_ques
 tion
@@ -1105,13 +1105,45 @@
 ,%0A  
-topic
+label: thinkyType.string(),%0A  fieldId
 : th
@@ -1283,16 +1283,45 @@
 alse%7D),%0A
+  name: thinkyType.string(),%0A
   schedu
@@ -1598,232 +1598,4 @@
 %5D%0A%7D)
-%0A%0ANote.belongsTo(Field, %22field%22, %22fieldId%22, %22id%22)%0AGroupCallInvitation.hasMany(GroupCall, %22groupCalls%22, %22id%22, %22groupCallInvitationId%22)%0AGroupCall.belongsTo(GroupCallInvitation, %22groupCallInvitation%22, %22groupCallInvitationId%22, %22id%22)

Update models