Custom objects in ArrowDB

Posted By : Pawanpreet Singh | 29-Jun-2015

Custom obejcts in ArrowDB are required when you want to save a thing which is not present in built in restful calls creted by Appcelerator. To overcome this situation one can create its own custom object to save that data. One can easily integrate these custom objects with the existing ArrowDB objects. Here I will give brief overview how can one use it in his/her app.

Create a custom object

 Cloud.Objects.create({
    classname: 'students',
    fields: {
        name: 'Pawanpreet',
        stream: 'medical',
        rollno: 5
    }
}, function (e) {
    if (e.success) {
        var student = e.students[0];
        alert('Success:\n' +
            'name: ' + student.name + '\n' +
            'stream: ' + student.stream + '\n' +
            'rollno: ' + student.rollno + '\n' +
            'created_at: ' + student.created_at);
    } else {
        alert('Error:\n' +
            ((e.error && e.message) || JSON.stringify(e)));
    }
});
 

 

The above code will create a new custom object named students, Custom object name will be the name of the classname which we have provided while creating a new object. Here we have added fields named - name, stream and rollno in it with its respective values.

 

Now its time to get the saved custom object for use in our app.

Getting the value of custom object

 Cloud.Objects.show({
    classname: 'students',
    ids: [ studentsIdReturnedFromServerAfterSaving ]
}, function (e) {
    if (e.success) {
        alert('Success:\n' +
            var car = e.students[0];
            alert('id: ' + students.name + '\n' +
                'rollno: ' + students.rollno + '\n' +
                'stream: ' + students.stream 
        }
    } else {
        alert('Error:\n' +
            ((e.error && e.message) || JSON.stringify(e)));
    }
});
 

About Author

Author Image
Pawanpreet Singh

Pawanpreet is an seasoned Project Manager with a wealth of knowledge in software development, specializing in frontend and mobile applications. He possesses a strong command of project management tools, including Jira, Trello, and others. With a proven track record, he has successfully overseen the delivery of multiple software development projects, managing budgets and large teams. Notable projects he has contributed to include TimeForge, Yogyata, Kairos, Veto, Inspirien App, and more. Pawanpreet excels in developing and maintaining project plans, schedules, and budgets, ensuring timely delivery while staying within allocated resources. He collaborates closely with clients to define project scope and requirements, establish timelines and milestones, and effectively manage expectations. Regular project status meetings are conducted by him, providing clients and stakeholders with consistent updates on project progress, risks, and issues. Additionally, he coaches and mentors project leads, offering guidance on project management best practices and supporting their professional development.

Request for Proposal

Name is required

Comment is required

Sending message..