Saving data object with boolean & date properties

In my app I have an array of objects, all fields in the object have string values. I need to iterate through the array and save each object to the database. However I do not want all the fields in the object to be saved to the database as strings, I want some to be saved as int, some as boolean, and some as date. I am trying to convert the strings to the desired value before saving to the database. This is working OK for ints, the strings are converted to ints and saved to the database as int values. But I cannot get it to work for boolean or date values. Booleans are being saved to the database as empty strings, dates are being saved as empty unknown type.

Here is the snippet code I am using to convert the string values and save to the database:

function Challenges1(args) {
    args = args || {};
    this.id = args.id || "";
    this.name = args.name || "";
    this.sub_category = args.sub_category || "";
    this.expiration = args.expiration || "";
    this.is_featured = args.is_featured || "";
}

var async = new Backendless.Async(
    function( success )
    {
        response.send( success );
    },
    function( failure )
    {
        response.send( failure );
    });

for (var i = 0; i < num_challenges; i++) {
    
    var challenge_id_int = parseInt(all_challenges.challenge_id);
    var challenge_sub_cat_int = parseInt(all_challenges.challenge_sub_category);
    var challenge_is_featured_bool;
    if (all_challenges.challenge_is_featured == "TRUE")
        {challenge_is_featured_bool = true;}
    else
        {challenge_is_featured_bool = false;}
    var challenge_expiration_date = new Date (all_challenges.challenge_expiraton);
    
    var current_challenge = new Challenges1( {
        id: challenge_id_int,
        name: all_challenges.challenge_name,
        sub_category: challenge_sub_cat_int,
        expiration: challenge_expiration_date,
        is_featured: challenge_is_featured_bool
    });

    var abc = Backendless.Persistence.of(Challenges1).save( current_challenge, async );
    }

What do I need to do to have the values saved in to the database as Boolean and DateTime types?

Still trying to get this working. Instead of converting the expiration_date filed to a Date object I edited the date format of the source data to match the format used in the backendless database (mm/dd/yyyy hh:mm:ss). Now the date items are being imported but they are being stored as strings rather than datetime values.

here is the format of the Challenges1 object that I am saving to the database:

{“id”:20021,“name”:“Classical Music”,“sub_category”:2002,“expiration”:“02/15/2015 13:00:00”,“is_featured”:true}

As mentioned above the “expiration” items is being saved as a string instead of a date and the “is_featured” item is saved as an empty string instead of boolean. Need to know how to get these items saved as the desired data types.

Hi!
Could you try to predefine column types using Backendless console:
go to Backendless app console -> Data tab -> select Challenges1 table -> go to Schema and Permissions -> add column “expiration” with data type “date time” and column “is_featured” with data type “boolean” and try to add Challenges1 data object again?
Regards,
Kate.

Thanks Kate, I pre-created the table with the desired data types as you suggested. It is working now for the datetime. For the boolean data type I am seeing strange behavior. It is only importing the object if the boolean value =true, all the objects that have the boolean field = false are skipped over and not saved to the database.

Actually the issues with the false booleans was a problem in my code. I can created both the datetime and boolean items in the datbase now. Thanks!