Hey Jason,

That at least looks like it should work. What is the error you get?

Regards,
koen


2014-03-25 19:19 GMT+01:00 Jason H <[email protected]>:

> Thanks. I've tried everything, including hat. My current is not working
> but here it is:
>
> class PostalCode
>
> {
>
>       public:
>
>               std::string code;
>
>               std::string state;
>
>               std::string city;
>
>
>               template<class Action>
>
>               void persist(Action& a)
>
>               {
>
>                       dbo::id   (a, code,  "code");
>
>                       dbo::field(a, state, "state");
>
>                       dbo::field(a, city,  "city");
>
>               }
>
> };
>
>
> namespace Wt {
>
>       namespace Dbo {
>
>
>               template<>
>
>               struct dbo_traits<PostalCode> : public dbo_default_traits {
>
>                       typedef std::string IdType;
>
>               
>       static const char *surrogateIdField() {
>
>                               return 0;
>
>                       }
>
>                       static const char *versionField() {
>
>                               return 0;
>
>                       }
>
>
>                       static IdType invalidId() {
>
>                         return IdType();
>
>                       }
>
>               };
>
>
>
>       }
>
> }
>
>
>   ------------------------------
>  *From:* Nagaev Boris <[email protected]>
> *To:* Jason H <[email protected]>; witty-interest <
> [email protected]>
> *Sent:* Tuesday, March 25, 2014 2:10 PM
> *Subject:* Re: [Wt-interest] Why : fatal error: Table postalCodes is
> missing a natural id defined with Wt::Dbo::id()"
>
> Hello,
>
> try to remove
>     dbo::field(a, code,  "code");
>
> You should not call dbo::field with field, used as ID.
>
>
> Regards,
> Boris Nagaev
>
>
> On Tue, Mar 25, 2014 at 9:36 PM, Jason H <[email protected]> wrote:
> >
> > This is my first experience using the Dbo module.
> >
> >
> > I don't know why it is giving me an error. The schema is (code text
> primary key, state text, city text) (SQLite3)
> >
> >
> >
> > class PostalCode
> >
> > {
> >
> > public:
> >
> > std::string code;
> >
> > std::string state;
> >
> > std::string city;
> >
> >
> > template<class Action>
> >
> > void persist(Action& a)
> >
> > {
> >
> > dbo::id  (a, code,  "code");
> >
> > dbo::field(a, code,  "code");
> >
> > dbo::field(a, state, "state");
> >
> > dbo::field(a, city,  "city");
> >
> > }
> >
> > };
> >
> >
> > namespace Wt {
> >
> > namespace Dbo {
> >
> >
> > template<>
> >
> > struct dbo_traits<PostalCode> : public dbo_default_traits {
> >
> > static const char *surrogateIdField() {
> >
> > return "code";
> >
> > }
> >
> > static const char *versionField() {
> >
> > return 0;
> >
> > }
> >
> > typedef std::string IdType;
> >
> >
> > static IdType invalidId() {
> >
> >  return std::string();
> >
> > }
> >
> > };
> >
> >
> > }
> >
> > }
> >
> >
> >
> ------------------------------------------------------------------------------
> > Learn Graph Databases - Download FREE O'Reilly Book
> > "Graph Databases" is the definitive new guide to graph databases and
> their
> > applications. Written by three acclaimed leaders in the field,
> > this first edition is now available. Download your free book today!
> > http://p.sf.net/sfu/13534_NeoTech
> > _______________________________________________
> > witty-interest mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/witty-interest
> >
>
>
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech
> _______________________________________________
> witty-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/witty-interest
>
>
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to