[v5] Update date with error "Unknown column '_zone' in 'field list'" #3206
Answered
by
jairochaves2
jairochaves2
asked this question in
Help
-
I am creating an event calendar.
Validator:import { schema, rules } from '@ioc:Adonis/Core/Validator'
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
export default class UpdateValidator {
constructor(protected ctx: HttpContextContract) {}
public schema = schema.create({
idLevelOfEducation: schema.number.optional([
rules.exists({ column: 'id', table: 'level_of_educations' }),
]),
year: schema.number.optional([rules.unsigned()]),
period: schema.number.optional([rules.unsigned()]),
startPeriod: schema.date.optional(),
endPeriod: schema.date.optional(),
notation: schema.string.optional({ trim: true }),
eventCalendarUrl: schema.string.optional({ trim: true }, [rules.url()]),
})
public messages = {}
} Modelimport { DateTime } from 'luxon'
import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm'
export default class CalendarEvent extends BaseModel {
@column({ isPrimary: true })
public id: number
@column()
public idCalendar: number
@column()
public eventName: string
@column.date()
public startEvent: DateTime
@column.date()
public endEvent: DateTime
@column.dateTime({ autoCreate: true })
public createdAt: DateTime
@column.dateTime({ autoCreate: true, autoUpdate: true })
public updatedAt: DateTime
} Controllerimport { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
import CalendarEvent from 'App/Models/CalendarEvent'
import CalendarEventStore from 'App/Validators/CalendarEvent/StoreValidator'
import CalendarEventUpdate from 'App/Validators/CalendarEvent/StoreValidator'
export default class CalendarEventsController {
public async store({ request }: HttpContextContract) {
const data = await request.validate(CalendarEventStore)
return await CalendarEvent.create(data)
}
public async update({ request, params }: HttpContextContract) {
const data = await request.validate(CalendarEventStore)
await CalendarEvent.query().where({ id: params.id }).update(data)
}
} Object of validate{
idCalendar: 1,
eventName: 'Provas 2',
startEvent: DateTime {
ts: 1632798000000,
_zone: SystemZone {},
loc: Locale {
locale: 'pt-BR',
numberingSystem: null,
outputCalendar: null,
intl: 'pt-BR',
weekdaysCache: [Object],
monthsCache: [Object],
meridiemCache: null,
eraCache: {},
specifiedLocale: null,
fastNumbersCached: null
},
invalid: null,
weekData: null,
c: {
year: 2021,
month: 9,
day: 28,
hour: 0,
minute: 0,
second: 0,
millisecond: 0
},
o: -180,
isLuxonDateTime: true
},
endEvent: DateTime {
ts: 1632970800000,
_zone: SystemZone {},
loc: Locale {
locale: 'pt-BR',
numberingSystem: null,
outputCalendar: null,
intl: 'pt-BR',
weekdaysCache: [Object],
monthsCache: [Object],
meridiemCache: null,
eraCache: {},
specifiedLocale: null,
fastNumbersCached: null
},
invalid: null,
weekData: null,
c: {
year: 2021,
month: 9,
day: 30,
hour: 0,
minute: 0,
second: 0,
millisecond: 0
},
o: -180,
isLuxonDateTime: true
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
jairochaves2
Sep 27, 2021
Replies: 1 comment 2 replies
-
I believe the contents of |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
jairochaves2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I believe the contents of
start_event
should be string when saving, but it is being passed without the ' character'start_period' = 2021-09-30 00:00:00.000 -03:00,