Truxton relation set b id

From truxwiki.com
Revision as of 07:04, 17 January 2021 by Sam (talk | contribs) (Created page with "This sets the B side of the relation in the sentence "A is a blank of B." This corresponds to the <code>[B_ID]</code> column of the the <code><nowiki>[</nowiki>Relation Tabl...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This sets the B side of the relation in the sentence "A is a blank of B." This corresponds to the [B_ID] column of the the [Relation] table in the database.

Syntax

void truxton_relation_set_b_id(uint64_t relation_handle, char const * id);

Parameters

relation_handle

The relation object to free. This handle comes from calling truxton_relation_create().

id

The string representation of a GUID.

Sample

 1 void set_primary_photo( uint64_t truxton, uint64_t media, uint64_t child_file )
 2 {
 3    char media_id[ 65 ];
 4    char file_id[ 65 ];
 5    
 6    truxton_media_get_id( media, media_id, sizeof( media_id ) );
 7    truxton_child_file_get_id( child_file, file_id, sizeof( file_id ) );
 8 
 9    uint64_t relation = truxton_relation_create( truxton );
10 
11    // Now tell Truxton that child_file (A object) is the primary photo of media (B object)
12    truxton_relation_set_relation( relation, RELATION_PRIMARY_PHOTO );
13 
14    // Set the A object, A is a file
15    truxton_relation_set_a_id( relation, file_id );
16    truxton_relation_set_a_type( relation, OBJECT_TYPE_FILE );
17 
18    // Set the B object, B is a piece of media
19    truxton_relation_set_b_id( relation, media_id );
20    truxton_relation_set_b_type( relation, OBJECT_TYPE_MEDIA );
21 
22    // Set the source object, source is a piece of media
23    truxton_relation_set_source_id( relation, media_id );
24    truxton_relation_set_source_type( relation, OBJECT_TYPE_MEDIA );
25 
26    // Commit the data to the database
27    truxton_relation_save( relation );
28    truxton_relation_destroy( relation );
29 }