{"id":21942082,"url":"https://github.com/richardzcode/contacts","last_synced_at":"2025-03-22T15:25:22.851Z","repository":{"id":2010003,"uuid":"2944398","full_name":"richardzcode/contacts","owner":"richardzcode","description":"Experimenting node.js Main purpose on finding best practice.","archived":false,"fork":false,"pushed_at":"2012-01-15T10:49:05.000Z","size":216,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-13T22:12:22.024Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/richardzcode.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-12-09T01:09:40.000Z","updated_at":"2013-10-16T23:33:00.000Z","dependencies_parsed_at":"2022-09-14T13:00:17.704Z","dependency_job_id":null,"html_url":"https://github.com/richardzcode/contacts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardzcode%2Fcontacts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardzcode%2Fcontacts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardzcode%2Fcontacts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardzcode%2Fcontacts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/richardzcode","download_url":"https://codeload.github.com/richardzcode/contacts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244976098,"owners_count":20541411,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-29T03:16:25.423Z","updated_at":"2025-03-22T15:25:22.822Z","avatar_url":"https://github.com/richardzcode.png","language":"JavaScript","readme":"# Contacts\n\nExperimenting node.js.\n\n## JavaScript Object\n\nExtended Object and Array a bit.\n\n#### Object.extend(from, replace)\nAdd properties of _from_ object to current object.\nIf same property exists, then replace if _replace_ is true. Default true.\n\n#### Object.subset(names)\nReturn a new object with subset of properties of current object.\n\n#### Array.merge(ary)\nMerge _ary_ into current array.\n\n## Context\n\nA context object is added to each request. It is used for template rendering.\n\n### Flash message\n\nContext object handles flash messages. Flash message is a kind of message that generated on business logic layer, supposed to be displayed to user once, and only once. It needs to handle case of redirect. Here we use session object to persist messages util they are renderred once.\n\nCurrently two type: error, info.\n\n#### context.error(msg)\nAdd error message[s]. _msg_ can be string or array of strings.\nIf no _msg_ supplied then return all errors.\n\n#### context.info(msg)\nAdd info message[s]. _msg_ can be string or array of strings.\nIf no _msg_ supplied then return all info messages.\n\n#### conext.clearFlash()\nClear flash messages from session.\n\n## Model\n\nThe first goal is to implemente Active Record pattern talk to MongoDB.\n\nModels are defined unser models/ directory. To use:\n\u003cpre\u003e\n\u003ccode\u003e\nvar Contact = require('../models').Contact;\nvar contact = new Contact();\n...\ncontact.bind(data);\ncontact.save(caller, callback);\n...\n\u003c/code\u003e\n\u003c/pre\u003e\n\nEach model only need to define FIELD_MAP to have basic methods\n\n* validate\n* bind\n* find\n* save\n* delete\n\nExample:\n\u003cpre\u003e\n\u003ccode\u003e\nmodule.exports.name = 'Contact';\n\nmodule.exports.klass = function(data) {\n  this.collection_name = 'contact';\n\n  this.FIELDMAP = {\n    name: {default: '', type: 'string', required: true},\n    owner_id: {default: '', type: 'ObjectId', required: true},\n    primary_contact_type: {default: '', type: 'string', required: true}, // email|phone|skype\n    primary_contact: {default: '', type: 'string', required: true},\n    created_on: {default: new Date(), type: 'datetime'},\n    modified_on: {default: new Date(), type: 'datetime'}\n  }\n\n  if (this.init) {\n    this.init(data);\n  }\n}\n\u003c/code\u003e\n\u003c/pre\u003e\n\nNot finished yet...\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichardzcode%2Fcontacts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frichardzcode%2Fcontacts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichardzcode%2Fcontacts/lists"}