<commit_before>_ = require 'lodash'
debug = require('debug')('meshblu:meshblu-db')

class MeshbluDb
  constructor: (@meshblu) ->

  find: (query, callback=->)=>
    @meshblu.devices query, (response) =>
      return callback new Error response.error if response.error
      callback null, response.devices

  findOne: (query, callback=->)=>
    @find query, (error, devices) => callback error, _.first(devices)

  update: (device, callback=->) => 
    @meshblu.update device, (response) =>
      return callback new Error(response.error) if response.error && !response.uuid 
      callback null, response    

  insert: (record, callback=->) =>
    debug "writing", record
    @meshblu.register record, (device) =>
      debug "insert response", device
      callback null, device

module.exports = MeshbluDb<commit_msg>error codes or something<commit_after>_ = require 'lodash'
debug = require('debug')('meshblu:meshblu-db')

class MeshbluDb
  constructor: (@meshblu) ->

  find: (query, callback=->)=>
    @meshblu.devices query, (response) =>
      debug response
      return callback new Error response.error?.message if response.error?
      callback null, response.devices

  findOne: (query, callback=->)=>
    @find query, (error, devices) => callback error, _.first(devices)

  update: (device, callback=->) => 
    @meshblu.update device, (response) =>
      return callback new Error(response.error?.message) if response.error? && !response.uuid 
      callback null, response    

  insert: (record, callback=->) =>
    debug "writing", record
    @meshblu.register record, (device) =>
      debug "insert response", device
      callback null, device

module.exports = MeshbluDb
{'fraction_non_alphanumeric': 0.13711583924349882, 'fraction_numerical': 0.0, 'mean_word_length': 3.6767955801104972, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, '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': '7111361', 'n_tokens_mistral': 512, 'n_tokens_neox': 497, 'n_words': 142}