{"id":1429,"date":"2012-08-29T02:15:03","date_gmt":"2012-08-28T17:15:03","guid":{"rendered":"http:\/\/pokosho.com\/b\/?p=1429"},"modified":"2013-02-18T13:32:46","modified_gmt":"2013-02-18T04:32:46","slug":"%e3%82%8f%e3%81%91%e3%81%a1%e3%83%81%e3%83%a3%e3%83%83%e3%83%88%e7%ac%91","status":"publish","type":"post","link":"https:\/\/pokosho.com\/b\/archives\/1429","title":{"rendered":"\u308f\u3051\u3061\u30c1\u30e3\u30c3\u30c8(\u7b11)"},"content":{"rendered":"<p><a href=\"http:\/\/pokosho.com\/b\/wp-content\/uploads\/2012\/08\/wchat.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1518\" title=\"wchat\" src=\"http:\/\/pokosho.com\/b\/wp-content\/uploads\/2012\/08\/wchat.png\" alt=\"\" width=\"400\" \/><\/a><\/p>\n<p>\u304a\u52c9\u5f37\u304c\u3066\u3089\u6bd4\u8f03\u7684\u65b0\u3057\u3044\u6280\u8853\u3092\u4f7f\u3063\u3066\u30c1\u30e3\u30c3\u30c8\u30a2\u30d7\u30ea\u3092\u4f5c\u308a\u307e\u3057\u305f\u3002<\/p>\n<ul>\n<li>\u6642\u3005\u3001<a href=\"http:\/\/twitter.com\/waketi\">@waketi<\/a> \u304c\u53e3\u3092\u631f\u3093\u3067\u304d\u307e\u3059\u3002<\/li>\n<li>\u5fc5\u305a\u8fd4\u4e8b\u304c\u6b32\u3057\u3044\u6642\u306f\u300c\u308f\u3051\u3061\u300d\u3068\u547c\u3073\u304b\u3051\u3066\u307f\u3066\u304f\u3060\u3055\u3044(\u305d\u308c\u3067\u3082\u8fd4\u4e8b\u3067\u304d\u306a\u3044\u3068\u304d\u306f\u3042\u308a\u307e\u3059\u304c\u2026)\u3002<\/li>\n<li>\u3042\u306a\u305f\u306e\u304a\u540d\u524d\u90e8\u5206\u306b\u306f\u3042\u306a\u305f\u306b\u3042\u3063\u305f\u8272\u306e\u30c6\u30ad\u30b9\u30c8\u306b\u3057\u3066\u304a\u304d\u307e\u3059\u306d<\/li>\n<li>\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u306b\u60aa\u3044\u4eba\u306f\u3044\u306a\u3044\u306e\u3067\u3042\u306a\u305f\u306b\u306a\u308a\u3059\u307e\u3059\u4eba\u304c\u73fe\u308c\u308b\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093(\u7b11)<\/li>\n<li>\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u306b\u60aa\u3044\u4eba\u306f\u3044\u306a\u3044\u306e\u3067\u6a5f\u5bc6\u60c5\u5831\u3092\u66f8\u3044\u3066\u3082\u554f\u984c\u3042\u308a\u307e\u305b\u3093(\u7b11)<\/li>\n<\/ul>\n<p><a href=\"http:\/\/pokosho.com:3000\/\">\u308f\u3051\u3061\u30c1\u30e3\u30c3\u30c8(\u7b11)<\/a><\/p>\n<p>URL\u3092\u898b\u305f\u6642\u70b9\u3067port 3000\u306a\u306e\u304c\u30c0\u30b5\u3044\u3067\u3059\u304c\u3001\u4eca\u5f8c\u306e\u8ab2\u984c\u3068\u3044\u3046\u3053\u3068\u3067\u2026\u3002<\/p>\n<h3>\u505c\u6b62\u3057\u307e\u3059\u3002\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3057\u305f\uff01(2013\/02)<\/h3>\n<p>\u4ed6\u306b\u52d5\u304b\u3057\u305f\u3044\u3082\u306e\u304c\u3067\u3066\u304d\u305f\u306e\u3067\u3001\u4e00\u65e6\u505c\u6b62\u3057\u307e\u3059\u3002<br \/>\n<a href=\"http:\/\/pokosho.com\/b\/wp-content\/uploads\/2012\/08\/waketichat.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1679\" title=\"waketichat\" src=\"http:\/\/pokosho.com\/b\/wp-content\/uploads\/2012\/08\/waketichat.png\" alt=\"\" width=\"400\" \/><\/a><br \/>\n\u8a18\u5ff5\u30b9\u30af\u30b7\u30e7\u306e\u305f\u3081\u8cd1\u3084\u304b\u306b\u3057\u3066\u3082\u3089\u3044\u307e\u3057\u305f\uff57 \u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<h3>\u3069\u3046\u4f5c\u3063\u305f\u304b\uff1f<\/h3>\n<p><a href=\"http:\/\/looseleafjs.org\/munode\/\">munode\u3055\u3093\u306eNode\u3067\u4f5c\u308b\u4eba\u5de5\u7121\u80fd<\/a>\u3092\u30d9\u30fc\u30b9\u306b\u4f5c\u308a\u307e\u3057\u305f\u3002<br \/>\n\u5206\u304b\u308a\u3084\u3059\u304f\u307e\u3068\u307e\u3063\u3066\u3044\u308b\u3057\u3001\u9762\u767d\u3044\uff01<\/p>\n<h4>\u4eba\u5de5\u7121\u80fd\u90e8\u5206<\/h4>\n<p>\u4eba\u5de5\u7121\u80fd\u90e8\u5206\u306f\u3059\u3067\u306b <a href=\"http:\/\/twitter.com\/waketi\">@waketi<\/a> \u3067\u3084\u3063\u3066\u3044\u308b\u306e\u3067\u3001@waketi \u306bHTTP\u30b5\u30fc\u30d0\u3092\u7528\u610f(\u30b5\u30fc\u30d6\u30ec\u30c3\u30c8\u3092\u305f\u3066\u308b\u306e\u306f\u5927\u3052\u3055\u304b\u306a\u3068\u601d\u3063\u305f\u306e\u3067com.sun.net.httpserver\u306b\u3057\u305f)\u3057REST API\u3092\u7528\u610f\u3057\u3001Node\u304b\u3089\u305d\u308c\u3092\u547c\u3073\u51fa\u3059\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>Node\u3001JS\u304b\u3089\u3069\u3046\u3084\u3063\u3066HTTP\u901a\u4fe1\u3059\u308b\u306e\u3084\u3089\u3001\u3068\u7591\u554f\u306b\u601d\u3044\u307e\u3057\u305f\u304c\u3001HTTP\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u3042\u308b\u3093\u3067\u3059\u306d\u3002<br \/>\nlocalhost:12345\u306bPOST\u3067\u30d1\u30e9\u30e1\u30fc\u30bfq\u3092\u9001\u3063\u3066\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n var http = require('http');\r\n\tvar options = {\r\n\t\thost: 'localhost',\r\n\t\tport: 12345,\r\n\t\tpath: '\/',\r\n\t\tmethod: 'POST'\r\n\t};\r\n\tvar req = http.request(options, function(res) {\r\n                \/\/ response\u51e6\u7406\r\n\t};\r\n        req.write('q='+msg+'\\n');\r\n        req.end();\r\n}\r\n<\/pre>\n<h4>DB<\/h4>\n<p>mongoose\u3092\u4f7f\u3063\u3066MongoDB\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\nmongoose\u306fORM\u98a8\u306bmongo\u3092\u4f7f\u3048\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002<br \/>\nmessage DB\u306emessage\u30c6\u30fc\u30d6\u30eb\u306eDAO\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\/\/ message.js\r\n\/\/ message model\r\nvar mongoose = require('mongoose');\r\nvar db = mongoose.connect('mongodb:\/\/localhost\/message',\r\n\t\tfunction(err) {\r\n\t\t\tif (err) {\r\n\t\t\t\tconsole.log(err);\r\n\t\t\t} else {\r\n\t\t\t\tconsole.log('connection success!');\r\n\t\t\t}\r\n\t\t}\r\n\t\t);\r\nvar Schema = mongoose.Schema;\r\n\r\nvar MessageSchema  = new Schema({\r\n\tname: String,\r\n\tmessage: String,\r\n\tcreated_at: Date\r\n});\r\nMessageSchema.pre('save', function(next) {\r\n\tconsole.log(&quot;pre save&quot;);\r\n\tif (this.isNew) {\r\n\t\tthis.created_at = new Date();\r\n\t}\r\n\tnext();\r\n});\r\n\/\/ define model\r\nmongoose.model('Message', MessageSchema);\r\nmodule.exports = db.model('Message');\r\n<\/pre>\n<p>\u306f\u307e\u3063\u305f\u306e\u306f\u3001message\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u3063\u305f\u3064\u3082\u308a\u304c\u3001\u4f5c\u6210\u3055\u308c\u308b\u30c6\u30fc\u30d6\u30eb\u540d\u306f message<em>s<\/em>\u306b\u306a\u308b\u3053\u3068\u3002<br \/>\n\u203b\u4f55\u3060\u304b\u52d8\u9055\u3044\u3092\u3057\u3066\u3044\u308b\u6c17\u3082\u3057\u307e\u3059(knife\u30e2\u30c7\u30eb\u3092\u3064\u304f\u308b\u3068knives\u306b\u306a\u308b\u306e?)<br \/>\n\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u3067\u4f5c\u3089\u308c\u308b\u30c6\u30fc\u30d6\u30eb\u306fmongo\u306e\u30b3\u30f3\u30bd\u30fc\u30eb\u304b\u3089\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nmongo\r\n&gt; show dbs\r\nadmin\t(empty)\r\nlocal\t(empty)\r\nmessage\t0.0625GB\r\n&gt; use message;\r\nswitched to db message\r\n&gt; show collections;\r\nmessages\r\nsystem.indexes\r\n<\/pre>\n<p>\u65b0\u3057\u3044\u9806\u306b\u6700\u65b0\u3001150\u4ef6\u3092\u53d6\u308b\u306e\u306f\u3053\u3093\u306a\u611f\u3058\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar Message = require('.\/lib\/model\/message.js');\r\nmsgs = Message.find().sort({created_at:-1}).limit(150).exec(function(err, msgs) {\r\n    \/\/ msgs \u51e6\u7406\r\n}\r\n<\/pre>\n<p>\u8a2d\u8a08\u304b\u3089\u3084\u308a\u76f4\u3057\u305f\u65b9\u304c\u826f\u3044\u30ec\u30d9\u30eb\u306e<a href=\"https:\/\/github.com\/kaibadash\/waketi_chat\/\">\u7cde\u30b3\u30fc\u30c9\u306f\u3053\u3061\u3089<\/a>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u304a\u52c9\u5f37\u304c\u3066\u3089\u6bd4\u8f03\u7684\u65b0\u3057\u3044\u6280\u8853\u3092\u4f7f\u3063\u3066\u30c1\u30e3\u30c3\u30c8\u30a2\u30d7\u30ea\u3092\u4f5c\u308a\u307e\u3057\u305f\u3002 \u6642\u3005\u3001@waketi \u304c\u53e3\u3092\u631f\u3093\u3067\u304d\u307e\u3059\u3002 \u5fc5\u305a\u8fd4\u4e8b\u304c\u6b32\u3057\u3044\u6642\u306f\u300c\u308f\u3051\u3061\u300d\u3068\u547c\u3073\u304b\u3051\u3066\u307f\u3066\u304f\u3060\u3055\u3044(\u305d\u308c\u3067\u3082\u8fd4\u4e8b\u3067\u304d\u306a\u3044\u3068\u304d\u306f\u3042\u308a\u307e\u3059\u304c\u2026)\u3002 \u3042\u306a\u305f\u306e\u304a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1518,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[7],"tags":[],"class_list":["post-1429","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-program"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pokosho.com\/b\/wp-json\/wp\/v2\/posts\/1429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pokosho.com\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pokosho.com\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pokosho.com\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pokosho.com\/b\/wp-json\/wp\/v2\/comments?post=1429"}],"version-history":[{"count":0,"href":"https:\/\/pokosho.com\/b\/wp-json\/wp\/v2\/posts\/1429\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pokosho.com\/b\/wp-json\/wp\/v2\/media\/1518"}],"wp:attachment":[{"href":"https:\/\/pokosho.com\/b\/wp-json\/wp\/v2\/media?parent=1429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pokosho.com\/b\/wp-json\/wp\/v2\/categories?post=1429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pokosho.com\/b\/wp-json\/wp\/v2\/tags?post=1429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}