<commit_before>const models = require('./models')
const Course = models.Course
const Student = models.Student
const path = require('path')
const url = require('url')

const uri = url.format({
    pathname: path.join(__dirname, 'data.db'),
    protocol: 'nedb:',
    slashes: true
})

const init = function(cb){
    models.init(uri, function(err){
	if(err){
	    console.log("Models initialization failed")
	    cb(err)
	}else{
	    console.log("Models initialized..")
	    cb()
	}
    })
}

const saveCourse = function(course, cb){
    let c = Course.create(course)
    c.save().then(function(doc){
	cb(null, doc._id)
    }, function(err){
	cb(err)
    })
}

const getCourse = function(course, cb){
    Course.findOne(course).then(function(doc){
	cb(null, doc)
    }, function(err){
	cb(err)
    })
}

const getCourses = function(course, cb){
    Course.find(course, {sort: '-startDate'}).then(function(docs){
	cb(null, docs)
    }, function(err){
	cb(err)
    })
}


const getStudents = function(student, cb){
    Student.find(student, {sort: 'name'}).then(function(docs){
	cb(null, docs)
    }, function(err){
	cb(err)
    })
}


const saveStudent = function(student, cb){
    let s = Student.create(student)
    s.save().then(function(doc){
	cb(null, doc._id)
    }, function(err){
	cb(err)
    })
}

module.exports = {
    init,
    saveCourse,
    getCourse,
    getCourses,
    getStudents,
    saveStudent
}
<commit_msg>Add api to add transaction<commit_after>const models = require('./models')
const Course = models.Course
const Student = models.Student
const Txn = models.Txn
const path = require('path')
const url = require('url')

const uri = url.format({
    pathname: path.join(__dirname, 'data.db'),
    protocol: 'nedb:',
    slashes: true
})

const init = function(cb){
    models.init(uri, function(err){
	if(err){
	    console.log("Models initialization failed")
	    cb(err)
	}else{
	    console.log("Models initialized..")
	    cb()
	}
    })
}

const saveCourse = function(course, cb){
    let c = Course.create(course)
    c.save().then(function(doc){
	cb(null, doc._id)
    }, function(err){
	cb(err)
    })
}

const getCourse = function(course, cb){
    Course.findOne(course).then(function(doc){
	cb(null, doc)
    }, function(err){
	cb(err)
    })
}

const getCourses = function(course, cb){
    Course.find(course, {sort: '-startDate'}).then(function(docs){
	cb(null, docs)
    }, function(err){
	cb(err)
    })
}


const getStudents = function(student, cb){
    Student.find(student, {sort: 'name'}).then(function(docs){
	cb(null, docs)
    }, function(err){
	cb(err)
    })
}


const saveStudent = function(student, cb){
    let s = Student.create(student)
    s.save().then(function(doc){
	cb(null, doc._id)
    }, function(err){
	cb(err)
    })
}

const saveTxn = function(txn, cb){
    let t = Txn.create(txn)
    t.save().then(function(doc){
	cb(null, doc._id)
    }, function(err){
	cb(err)
    })
}

module.exports = {
    init,
    saveCourse,
    getCourse,
    getCourses,
    getStudents,
    saveStudent,
    saveTxn
}

{'fraction_non_alphanumeric': 0.16933638443935928, 'fraction_numerical': 0.0, 'mean_word_length': 3.402877697841727, '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': '5581174', 'n_tokens_mistral': 1109, 'n_tokens_neox': 1078, 'n_words': 222}