Parse & JS: Destroying objects

As in any other OOP style of programming, an object can be destroyed to release it from the memory.

In the example below, it will insert 3 records to MovObject.

Once done, the MovObject will be destroyed.

<!doctype html>
<head>
    <title>My Parse App</title>
    <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
    <script type='text/javascript' src='http://www.parsecdn.com/js/parse-1.2.17.min.js'></script>
</head>

<body>

<div>
    <div style='display:none' class='error'>
        <h1>Failed to connect to Parse database</h1>
    </div>

    <div style='display:none' class='success'>
        <h1>Successfully inserted the movies</h1>
    </div>
</div>

<script>
    Parse.initialize('5d3sro43zBGj8AMYqWND5bFYMzAan7f5P5euZm7M', 'hlRZZqAylA7Fmah4Kk6ma8WK7QCT4cHrxjafnnkI');
    var MovObject = Parse.Object.extend('MovObject');
    var movObject = new MovObject();

    movObject.set('titleName', 'Dallas Buyers Club' );
    movObject.set('actorName', 'Matthew McConaughey');
    movObject.set('releaseYear', 2013);

    movObject.save(null, {
        success: function (object) {
        },
        error: function (model, error) {
        }
    })

    movObject.destroy({
        success: function(movObject) {
        },
        error: function(movObject, error) {
        }
    });

    var movObject = new MovObject();

    movObject.set('titleName', 'Ender Games');
    movObject.set('actorName', 'Asa Butterfield');
    movObject.set('releaseYear', 2012);

    movObject.save(null, {
        success: function (movObject) {
        },
        error: function (movObject, error) {
        }
    })

    movObject.destroy({
        success: function(movObject) {
        },
        error: function(movObject, error) {
        }
    });

    var movObject = new MovObject();

    movObject.set('titleName', 'Scent Of A Woman');
    movObject.set('actorName', 'Al Pacino');
    movObject.set('releaseYear', 1993);

    movObject.save(null, {
        success: function (movObject) {
            $('.success').show();
        },
        error: function (movObject, error) {
            $('.error').show();
        }
    })

</script>

</body>
</html>
Try The Code

movObject

Series Navigation<< Parse & JS: Retrieving refreshed object
Parse & JS: Basic Query >>