Domanda

I'm building a web application in yesod with mongodb.

I'm tryign to create a model called Message:

Message _id Text threadKey Text body Text

But I can't seem to access the _id field this way, the message_id function doesn't get created, unlike messageThreadKey and messageBody.

How can I access the _id field of mongo objects from yesod/persistent-mongoDB?

È stato utile?

Soluzione

In persistent the id (in both the SQL version and the Mongo version) is special and not actually part of the model record. The combination of a Id and a Model Record is called an Entity.

I would reread the persistent chapter of the Yesod book under the Manipulation section, Insert subsection.

http://www.yesodweb.com/book/persistent

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top