[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Artanis] Foreign Key for Migrations

From: Nala Ginrut
Subject: Re: [Artanis] Foreign Key for Migrations
Date: Sun, 17 Mar 2019 04:31:11 +0800
User-agent: mu4e 1.0; emacs 25.1.1

Hi Jonathan!
Sorry it's my mistake to neglect this part in the doc.
You don't have to take care of the DB connection management by
yourself. You may just use `art draw model person' to create the named
mapping to the "person" table, and there's an exported relational
mapping object named "$person", you may import (app models person) in
other controller to use it. It's based on FPRM, but the table name has
already been wrapped into the closure:

And maybe read its implementation is clearer to you:

The usage should look like this:

($person 'set #:name "nala" #:age 100)

BTW, please don't forget to config your DB in conf/artanis.conf first.

Best regards.

Jonathan Schmeling writes:

> Gotcha. That makes a lot of sense. Thanks a ton for explaining!
> Database related, is there a way to query the database from one of the 
> controller -define methods (like (article-define show …) in the online 
> documentation)? Using the function map-table-from-DB causes an error and 
> attaching #:conn #t, like with the get function, also causes an error. Doing 
> something like (:conn rc "SELECT * FROM PEOPLE") seems to work (or, at least, 
> not throw an error) but I'm not sure what gets returned. The doc. says the 
> returned value is described at 
> but that 
> section says "TODO".
> As always, any help is always super appreciated!
> Jonathan
> On 2/17/19 12:19 PM, Nala Ginrut wrote:
> Hi Jonathan!
> I'm glad you asked this question.
> The answer is actually written in the fprm.scm code comments that the
> relational mapping in Artanis is not going to provide database level
> foreign keys. The solution is to provide higher-abstract-level table
> operations as a replacement to save users to time to handle by
> themselves.
> The pros and cons of foreign keys are discussed a lot in the
> internet. The modern ORM may choose to drop foreign keys and provide
> higher layer for it.
> Unfortunately, this feature has not been implemented yet because of my time 
> schedule.
> Of course, this issue is still open, the original plan is more
> ambitious. I think it's the time to add more features to the relational
> mapping framework.
> Welcome to discuss if you like.
> Best regards.
> Jonathan Schmeling writes:
> I'm not sure if it's been asked before but I couldn't find any mention
> in the doc. – is it feasible to define foreign keys for the create-table
> function? I want to reference another table's primary keys from a
> particular table, to link them.
> Jonathan

GNU Powered it
GPL Protected it
GOD Blessed it
HFG - NalaGinrut
Fingerprint F53B 4C56 95B5 E4D5 6093 4324 8469 6772 846A 0058

Attachment: signature.asc
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]