<commit_before>Backbone.Repository
===================

Repository plugin for Backbone

### Usage

Fetch models or collections using the built-in methods, or create your own:

    // Extending Backbone.Repository
    var UserRepository = Backbone.Repository.extend({
        modelType: User,
        collectionType: UserCollection
    });

    // Create an instance
    var userRepo = new UserRepository();

    // Fetch data
    var findingUsers = userRepo.findAll();

    // Uses jQuery promises
    $.when(findingUsers)
        .done(function (response) {
            var view = new UsersListView({ collection: response });
            // etc...
        })
        .fail(function (response) {
            var jsonReponse = $.parseJSON(response);
            // etc...
        });

Use criteria to filter a result:

    // Fetch data
    var findingUser = userRepo.findOneBy({ username: 'wmozart' });

    // Uses jQuery promises
    $.when(findingUser)
        .done(function (response) {
            var view = new UserDetailView({ model: response });
            // etc...
        })
        .fail(function (response) {
            var jsonResponse = $.parseJSON(response);
        });

Save new models with a collection or stand-alone, and update or remove existing models:

    // New model data
    var modelData = {
        username: 'ljenkins'
    };

    // Add to an existing collection
    var userCollection = this.userCollection;
    var savingUser = userRepo.insert(userCollection, modelData);
    $.when(savingUser)
        .done(function (response) { /* success */ })
        .fail(function (response) { /* error */ });

    // Persist or update a model
    var user = new User();
    var savingUser = userRepo.save(user, modelData);
    $.when(savingUser)
        .done(function (response) { /* success */ })
        .fail(function (response) { /* error */ });

    // Remove a model from persistence and any collections<commit_msg>formatting<commit_after>Backbone.Repository
===================

Repository plugin for Backbone

### Usage

Fetch models or collections using the built-in methods, or create your own:

    // Extending Backbone.Repository
    var UserRepository = Backbone.Repository.extend({
        modelType: User,
        collectionType: UserCollection
    });

    // Create an instance
    var userRepo = new UserRepository();

    // Fetch data
    var findingUsers = userRepo.findAll();

    // Uses jQuery promises
    $.when(findingUsers)
        .done(function (response) {
            var view = new UsersListView({ collection: response });
            // etc...
        })
        .fail(function (response) {
            var jsonReponse = $.parseJSON(response);
            // etc...
        });

Use criteria to filter a result:

    // Fetch data
    var findingUser = userRepo.findOneBy({ username: 'wmozart' });

    // Uses jQuery promises
    $.when(findingUser)
        .done(function (response) {
            var view = new UserDetailView({ model: response });
            // etc...
        })
        .fail(function (response) {
            var jsonResponse = $.parseJSON(response);
            // etc...
        });

Save new models with a collection or stand-alone, and update or remove existing models:

    // New model data
    var modelData = {
        username: 'ljenkins'
    };

    // Add to an existing collection
    var userCollection = this.userCollection;
    var savingUser = userRepo.insert(userCollection, modelData);
    $.when(savingUser)
        .done(function (response) { /* success */ })
        .fail(function (response) { /* error */ });

    // Persist or update a model
    var user = new User();
    var savingUser = userRepo.save(user, modelData);
    $.when(savingUser)
        .done(function (response) { /* success */ })
        .fail(function (response) { /* error */ });

    // Remove a model from persistence and any collections
{'fraction_non_alphanumeric': 0.1252231573578169, 'fraction_numerical': 0.0, 'mean_word_length': 2.20949263502455, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4834150', 'n_tokens_mistral': 1041, 'n_tokens_neox': 1012, 'n_words': 314}