#πŸ›‘ Can't find field 'createdAt' in Model, but it was specified in the primary key.

3 messages Β· Page 1 of 1 (latest)

stable kraken
#

The docs state helper fields createdAt and updatedAt are automatically added to your type with @model

This is a snippet of my model:

``
type Post @model @auth(rules: [{ allow: public, operations: [read] }, { allow: owner }]) @searchable {
id: ID! @primaryKey(sortKeyFields: ["createdAt"])

comments: [Comment] @hasMany
likes: [Like] @hasMany

}``

I did not specify createdAt as a field because then, I'm not sure if it will still get automatically filled with values. Is it necessary to make it a field and if so, how can I make sure the default action of it being assigned the current createdTime and updatedTimes are met?

Would appreciate the help!

restive gust
#

I have observed that if you want to use createdAt or updatedAt in the indexes, you will have to declare them in the schema. For me they are still automatically created and&or updated.

Just an example, on other model I have updatedAt as well in the schema.

  createdAt: AWSDateTime! # Put here to use as a index (Amplify auto-generates this field too)
stable kraken