Quantcast
Channel: Adobe Community: Message List - ColdFusion
Viewing all articles
Browse latest Browse all 21760

Orm get only the id from child object

$
0
0

I'm new to orm, and I'm making some tests.

 

I've two simple object Artist and Art:

 

Artist.cfc

 

  // identifier

  property name="ArtistID" fieldtype="id" generator="native";

 

  // properties

  property name="Firstname";

  property name="Lastname";

  property name="Address";

  property name="City";

  property name="State";

  property name="PostalCode";

  property name="Email";

  property name="Phone";

  property name="Fax";

  property name="ThePassword";

 

  /* one artist can have many... */

 

 

  /* return an array of Art objects */

  property name="Art" fieldtype="one-to-many" cfc="Art" fkcolumn="ArtistID" type="array" orderby="Price Asc";

 

 

Art.cfc

 

  // identifier

  property name="ArtID" fieldtype="id" generator="native" ;

 

  // properties

  property name="ArtName" ;

  property name="Description" ;

  property name="Price" ;

  property name="LargeImage" ;

  property name="IsSold" ;

 

  property name="Artist" fieldtype="many-to-one" fkcolumn="ArtistID" cfc="Artist"; 

 

 

When I try to get an artist:

 

 

   artist = EntityLoadByPK("Artist", 1);

 

I get a response with a struct with all the artist property, and an array of child art with all properties. (I have serialized in the example)

 

{"ArtistID":1,"Firstname":"Leonardo","Lastname":"Da vinci","City":"NewYork","Art":[{"ArtID":1,"ArtName":"landscape","Pric e":"1500","IsSold":"false","Artist":null},{"ArtID":2,"ArtName":"landsc ape","Price":"1500","IsSold":"false","Artist":null}]

 

I would like to retrieve not all the properties of child art, but only the primary key. Is this possible with Orm?


Viewing all articles
Browse latest Browse all 21760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>