<commit_before>function read(context, callback) {

    /**
     * Default read operation for the object of interest, with no other business logic.
     * It reads the object from mongodb.
     * In order to determine what table (collection) to use, it looks first for the "collection"
     * link, which defines that collection an item is within. If this link is not present,
     * we are dealing with an actual collection, in which case the "self" link is used.
     */

    var mongodb = require("mongodb"),
        dbstring = "mongodb://test:<EMAIL>:10045/dysxI4lRS8s1qBCj5pzDUw";

    mongodb.MongoClient.connect(dbstring, function (err, db) {

        var c,
            self,
            coll,
            cname,
            link = context.link;

        context.links.forEach(function (link) {
            if (link.rel === "schema/rel/collection") {
                coll = link.schema['$ref'].substring(link.schema['$ref'].lastIndexOf("/") + 1);
            } else if (link.rel === "schema/rel/self") {
                self = link.schema['$ref'].substring(link.schema['$ref'].lastIndexOf("/") + 1);
            }
        });
        cname = coll || self;

        console.log("executing default read logic for " + cname);

        db.collection(cname, function (err, col) {

            if (!coll) {
                col.find().toArray(function (err, docs) {
                    if (docs === null) {
                        docs = [];
                    }
                    context.result = {
                        items: docs
                    };
                    callback(context);
                });
            } else {
                col.findOne({_id: context.params.uri}, function (err, doc) {
                    context.result = doc;
                    callback(context);
                });
            }
            db.close();

        });

    });<commit_msg>Put it in the right spot...<commit_after>function read(context, callback) {

    /**
     * Default read operation for the object of interest, with no other business logic.
     * It reads the object from mongodb.
     * In order to determine what table (collection) to use, it looks first for the "collection"
     * link, which defines that collection an item is within. If this link is not present,
     * we are dealing with an actual collection, in which case the "self" link is used.
     */

    var mongodb = require("mongodb"),
        dbstring = "mongodb://test:<EMAIL>:10045/dysxI4lRS8s1qBCj5pzDUw";

    mongodb.MongoClient.connect(dbstring, function (err, db) {

        var c,
            self,
            coll,
            cname,
            link = context.link;

        context.links.forEach(function (link) {
            if (link.rel === "schema/rel/collection") {
                coll = link.schema['$ref'].substring(link.schema['$ref'].lastIndexOf("/") + 1);
            } else if (link.rel === "schema/rel/self") {
                self = link.schema['$ref'].substring(link.schema['$ref'].lastIndexOf("/") + 1);
            }
        });
        cname = coll || self;

        console.log("executing default read logic for " + cname);

        db.collection(cname, function (err, col) {

            if (!coll) {
                col.find().toArray(function (err, docs) {
                    if (docs === null) {
                        docs = [];
                    }
                    context.result = {
                        items: docs
                    };
                    callback(context);
                    db.close();
                });
            } else {
                col.findOne({_id: context.params.uri}, function (err, doc) {
                    context.result = doc;
                    callback(context);
                    db.close();
                });
            }

        });

    });
{'fraction_non_alphanumeric': 0.12382690302398332, 'fraction_numerical': 0.005735140771637122, 'mean_word_length': 1.4707018673535093, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4991617', 'n_tokens_mistral': 1065, 'n_tokens_neox': 986, 'n_words': 274}