Truxton artifact save

From truxwiki.com
Jump to navigation Jump to search

This saves an artifact object. The data in the artifact object will be written to the [Entity] table in the database. This will cause a record to be created in the [Entity] table.

Syntax

int truxton_artifact_save( uint64_t artifact_handle );

Parameters

artifact_handle

The artifact instance. This handle comes from calling truxton_artifact_create().

Return value

A non-zero value on success, zero on failure.

Sample

void create_artifact( void )
{
   uint64_t truxton = truxton_create();

   uint64_t artifact = truxton_artifact_create( truxton );

   truxton_artifact_set_name( artifact, "Ducky Momo Server" );

   // Commit the data to the database 
   if ( truxton_artifact_save( artifact ) == 0 )
   {
      printf( "Cannot save data to the database.\n" );
   }
   else
   {
      truxton_artifact_tag( artifact, "Too Young", "Yes, yes I am", 1 );

      char id[ 65 ];

      truxton_artifact_get_id( artifact, id, sizeof( id ) );

      printf( "Artifact ID is %s\n", id );
   }

   truxton_artifact_destroy( artifact );
   truxton_destroy( truxton );
}