{"_id":"node-ar","_rev":"5-445218f3919ba825c6f71d794502ff6d","name":"node-ar","description":"A simple nodejs module as active-record does","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"node-ar","version":"0.0.1","dependencies":{"mysql-libmysqlclient":"latest","logging":"latest"},"devDependencies":{},"engines":{"node":">= 0.5.0"},"author":{"name":"Fatshotty","email":"fat@fatshotty.net","url":"https://github.com/fatshotty"},"description":"A simple nodejs module as active-record does","homepage":"https://github.com/fatshotty/node-ar","repository":{"type":"git","url":"git://github.com/fatshotty/node-ar.git"},"scripts":{"test":"jasmine-node --color --verbose spec/"},"_npmUser":{"name":"fatshotty","email":"fat@fatshotty.net"},"_id":"node-ar@0.0.1","_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.6.2","_defaultsLoaded":true,"dist":{"shasum":"9a0bdd420c453b5f8ff203fc4f21a5bd9ed8b754","tarball":"https://registry.npmjs.org/node-ar/-/node-ar-0.0.1.tgz","integrity":"sha512-DpK561bl9MQqxvo/6zM9j+532iD43+Qtbc1bSpF5rnBkCkwOwd489yHxFtrvml5Li1pcWlNLUoJZp9v+4B5cyA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGl/WlVaGgIfC9sy4CiiDGEjbaRInq8gNsKKp1jY5W70AiEA5ziRo9/eDIlyhTgy0s1OPmvD9x0D/5spDQ44VL7rfXc="}]},"maintainers":[{"name":"fatshotty","email":"fat@fatshotty.net"}]}},"readme":"# node-ar\n\n## Purpose\n\nA simple ActiveRecord like nodejs module\n\nIt supports 'has_many' and 'belongs_to' relationship\n\nYou can `find` and `find_by*` each field name\n\n**Important**: it works synchronously.\n\n## Introduction\n\nThis module is based on Sannis's [node-mysql-libmysqlclient](https://github.com/Sannis/node-mysql-libmysqlclient).\nNode-Ar adds some simple features as ActiveRecord does.\nI want to explain that it is not completed. This should be considered an example.\nBut I would to expand it also with your help.\n\nSo, do not hesitate to contact me for any question or doubts\n\nMy mind is open for any collaboration ;)\n\n## Installation\n\nFor installing this module try\n\n```\nnpm install node-ar\n```\n\n## Usage\n\nSee file in the `spec` folder for examples\n\n\n## Overview\nHaving a DB as ActiveRecord on Rails wants.\nYou can able to perform `select` `insert` and `update` using `Models` like instances.\n\n### DataType (used to declare the fields)\nDataType.String           # the VARCHAR type\nDataType.Int              # the INT type\nDataType.Boolean          # the TYNINT type\n(tmporarly incompleted)\n\n### Model\n(Static methods)\nModel.find( id /* as NUM */ )   # returns the instance of the model if found. Otherwise null\nModel.find( 'all' )             # returns an Array instance contaning all model found by performing the `select`. Empty array if no record found\nModel.find( 'first' )           # returns the instance of the model representing the first matched record if found. Otherwise null\nModel.find_by( where, options, limit )\n    # where (Object)\n    ```javascipt\n    where = {\n      field_foo_name: field_foo_value,\n      field_bar_name: field_bar_value,\n    }\n    ```\n    # options (Object)\n    ```javascript\n    options = {\n      includes: ['table_foo_name', 'table_bar_name'],\n      joins: {\n        table_foo_name: {                       // INNER JOIN table_foo_name\n          field_bar_name: {                     // ON  field_bar_name\n            table_xxxx_name: 'field_xxxx_name'  // = table_xxxx_name.field_xxxx_name\n          }\n        }\n      }\n    }\n    ```\n    # limit (Number)    Used as `LIMIT` sql condition\n\nModel.find_by_foo_field_name( value )     # return an Array containing the result of `select * from table_foo_name where FOO_FIELD_NAME = VALUE`. A Model single instance if field id declared as unique\n\n\n## Todo\n\nWhat i'm going to add:\n\n* Implement events\n* Fields validation\n* BUG: it doesn't delete the `has_many` relations while deleting a Model from DB. But I'm working to fix it.\n\n* More documentation is coming... ;)\n","maintainers":[{"name":"fatshotty","email":"fat@fatshotty.net"}],"time":{"modified":"2022-06-21T11:56:21.821Z","created":"2011-12-05T23:17:41.572Z","0.0.1":"2011-12-05T23:17:43.191Z"},"author":{"name":"Fatshotty","email":"fat@fatshotty.net","url":"https://github.com/fatshotty"},"repository":{"type":"git","url":"git://github.com/fatshotty/node-ar.git"}}