{"id":2448,"date":"2016-12-20T15:00:00","date_gmt":"2016-12-20T15:00:00","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=2448"},"modified":"2025-06-13T21:40:24","modified_gmt":"2025-06-14T04:40:24","slug":"create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/ko\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/","title":{"rendered":"Node.js \ubc0f Couchbase\uc640 \ud568\uaed8 Ottoman ODM\uc744 \uc0ac\uc6a9\ud558\uc5ec URL \ub2e8\ucd95\uae30 \ub9cc\ub4e4\uae30"},"content":{"rendered":"<p>\uc5bc\ub9c8 \uc804\uae4c\uc9c0\ub9cc \ud574\ub3c4 <a href=\"https:\/\/www.couchbase.com\/blog\/ko\/create-a-url-shortener-with-nodejs-and-couchbase-using-n1ql\/\">Node.js \ubc0f Couchbase N1QL\ub85c URL \ub2e8\ucd95\uae30 \ub9cc\ub4e4\uae30<\/a>. \uc544\uc9c1 \uc77d\uc5b4\ubcf4\uc9c0 \uc54a\uc73c\uc168\ub2e4\uba74, \uc774 \uae00\uc740 Couchbase\uc640 RESTful API \ub9cc\ub4e4\uae30\uc5d0 \ub300\ud55c \ud6cc\ub96d\ud55c \uc18c\uac1c\uc785\ub2c8\ub2e4. <a href=\"https:\/\/www.couchbase.com\/blog\/ko\/build-a-rest-api-with-node-js-express-and-couchbase\/\">Node.js \uc0ac\uc6a9<\/a> \ubc0f Express \ud504\ub808\uc784\uc6cc\ud06c\uc5d0 \ub300\ud574 \uc124\uba85\ud569\ub2c8\ub2e4. \uc774 \uae00\uc758 \ud575\uc2ec\uc740 NoSQL \ub370\uc774\ud130\ub97c \uad00\ub9ac\ud558\ub824\uba74 SQL \ucffc\ub9ac\ub97c \uc791\uc131\ud558\ub294 \uac83\uc744 \uc120\ud638\ud574\uc57c \ud55c\ub2e4\ub294 \uac83\uc785\ub2c8\ub2e4.<\/p>\n<p>\ucffc\ub9ac\ub97c \uc791\uc131\ud558\ub294 \ub300\uc2e0 ODM(\uac1d\uccb4 \ubb38\uc11c \ubaa8\ub378)\uc744 \uc0ac\uc6a9\ud558\ub824\uba74 \uc5b4\ub5bb\uac8c \ud574\uc57c \ud558\ub098\uc694?<\/p>\n<p>\uc774\ubc88\uc5d0\ub294 \uc624\uc2a4\ub9cc ODM, \uce74\uc6b0\uce58\ubca0\uc774\uc2a4 \uc11c\ubc84, Node.js\ub97c \uc0ac\uc6a9\ud558\ub294 URL \ub2e8\ucd95\uae30\ub97c \ub9cc\ub4dc\ub294 \uac1c\ubc1c \ud504\ub85c\uc138\uc2a4\ub97c \uc0b4\ud3b4\ubcf4\uaca0\uc2b5\ub2c8\ub2e4.<\/p>\n<h2 id=\"the-requirements\">\uc694\uad6c \uc0ac\ud56d<\/h2>\n<p>\uc774 \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc758 \uc131\uacf5\uc5d0 \ud544\uc694\ud55c \uc694\uad6c \uc0ac\ud56d\uc740 \ub9ce\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uc5b4 \uc124\uce58 \ubc0f \uad6c\uc131\uc5d0 \ud544\uc694\ud55c \uc0ac\ud56d\uc740 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4:<\/p>\n<ul>\n<li>\uce74\uc6b0\uce58\ubca0\uc774\uc2a4 \uc11c\ubc84 4.1+<\/li>\n<li>Node.js 4.0+<\/li>\n<\/ul>\n<p>\uc774 \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc740 Node.js \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc774\ubbc0\ub85c \uc124\uce58\uac00 \ud544\uc694\ud558\uba70 \ubaa8\ub4e0 \ud504\ub85c\uc81d\ud2b8 \uc885\uc18d\uc131\uc744 \uc218\uc9d1\ud558\uae30 \uc704\ud574 Node \ud328\ud0a4\uc9c0 \uad00\ub9ac\uc790(NPM)\ub97c \uc0ac\uc6a9\ud560 \uac83\uc785\ub2c8\ub2e4. Ottoman\uc744 \ucd5c\ub300\ud55c \ud65c\uc6a9\ud558\ub824\uba74 Couchbase 4.1 \uc774\uc0c1\uc744 \uc0ac\uc6a9\ud558\ub294 \uac83\uc774 \uc88b\uc2b5\ub2c8\ub2e4.<\/p>\n<h2 id=\"understanding-the-data-model-and-preparing-the-couchbase-database\">\ub370\uc774\ud130 \ubaa8\ub378 \uc774\ud574 \ubc0f \uce74\uc6b0\uce58\ubca0\uc774\uc2a4 \ub370\uc774\ud130\ubca0\uc774\uc2a4 \uc900\ube44\ud558\uae30<\/h2>\n<p>\uc774 \uc608\uc81c\uc5d0\uc11c\ub294 \ub2e4\uc74c\uacfc \uac19\uc740 \ubc84\ud0b7\uc744 \ub9cc\ub4e4\uaca0\uc2b5\ub2c8\ub2e4. <strong>\uc608\uc81c<\/strong> \ub97c \uc0ac\uc6a9\ud569\ub2c8\ub2e4. \uad73\uc774 \uc774\ub807\uac8c \ubd80\ub974\uc9c0 \uc54a\uc544\ub3c4 \ub418\uc9c0\ub9cc \uc774 \uae00\uc5d0\uc11c\ub294 \uadf8\ub807\uac8c \ubd80\ub97c \uac83\uc785\ub2c8\ub2e4. \ubc84\ud0b7\uc744 \uc0dd\uc131\ud558\ub294 \uac83 \uc678\uc5d0 \ud074\ub7ec\uc2a4\ud130\uc5d0\uc11c \uc778\ub371\uc2a4\ub098 \ucd94\uac00 \uc124\uc815\uc774 \ud544\uc694\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.<\/p>\n<p>\ub370\uc774\ud130 \uce21\uba74\uc5d0\uc11c \ubcf4\uba74, \ucd95\uc18c\ud558\ub824\ub294 URL \ud558\ub098\ub2f9 \ud558\ub098\uc758 \ubb38\uc11c\ub97c \uc800\uc7a5\ud558\ub294 \uac83\uc774 \uacc4\ud68d\uc785\ub2c8\ub2e4. \uac01 \ubb38\uc11c\ub294 \ub2e4\uc74c\uacfc \uac19\uc774 \ubcf4\uc77c \uc218 \uc788\uc2b5\ub2c8\ub2e4:<\/p>\n<pre><code>{\r\n  \"_type\": \"Url\",\r\n  \"hash\": \"2xmx9qpyj\",\r\n  \"longUrl\": \"https:\/\/www.thepolyglotdeveloper.com\/2016\/05\/using-couchbase-nosql-nativescript-angular-2-mobile-app\/\",\r\n  \"shortUrl\": \"https:\/\/localhost:3000\/2xmx9qpyj\"\r\n}<\/code><\/pre>\n<p>\uadf8\ub9ac\uace0 <code>_\uc720\ud615<\/code> \uc18d\uc131\uc740 \uc624\uc2a4\ub9cc \ubaa8\ub378\uc5d0 \uc758\ud574 \uc815\uc758\ub41c \uac83\uc774\uc9c0\ub9cc \ub098\uba38\uc9c0 \uc138 \uac1c\ub294 \uc6b0\ub9ac\uac00 \uc815\uc758\ud560 \uc18d\uc131\uc785\ub2c8\ub2e4. \ud574\uc2dc\ub294 \uac12\uc758 \uace0\uc720\ud55c \ud574\uc2dc\ub97c \ub098\ud0c0\ub0c5\ub2c8\ub2e4. \uc774 \ud574\uc2dc\ub294 \uac01\uac01\uc758 \uc9e7\uc740 URL\uc5d0\uc11c \uc2dd\ubcc4\uc790 \uc5ed\ud560\uc744 \ud558\uac8c \ub429\ub2c8\ub2e4.<\/p>\n<h2 id=\"developing-the-node.js-url-shortener-application\">Node.js URL \ub2e8\ucd95\uae30 \uc560\ud50c\ub9ac\ucf00\uc774\uc158 \uac1c\ubc1c\ud558\uae30<\/h2>\n<p>\ub370\uc774\ud130\ubca0\uc774\uc2a4\uac00 \uc900\ube44\ub418\uace0 \ub370\uc774\ud130 \ubaa8\ub378\uc5d0 \ub300\ud55c \uae30\ubcf8\uc801\uc778 \uc774\ud574\uac00 \uc644\ub8cc\ub418\uc5c8\uc73c\ubbc0\ub85c \uc774\uc81c Node.js URL \ub2e8\ucd95\uae30 \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \ub9cc\ub4e4 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc774 \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc740 Express \ud504\ub808\uc784\uc6cc\ud06c\uc640 \ub2e4\uc74c\uacfc \uac19\uc740 \ub77c\uc774\ube0c\ub7ec\ub9ac\uc5d0 \ud06c\uac8c \uc758\uc874\ud558\uac8c \ub429\ub2c8\ub2e4. <a href=\"https:\/\/www.npmjs.com\/package\/hashids\">\ud574\uc2dc\ub4dc<\/a>. \ud574\uc2dc\ub4dc\ub97c \uc0ac\uc6a9\ud558\uba74 \uc9c1\uc811 \uc9e7\uc740 \ud574\uc2f1 \uc54c\uace0\ub9ac\uc998\uc744 \uc791\uc131\ud574\uc57c \ud558\ub294 \uc218\uace0\ub97c \ub35c \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<h3 id=\"creating-the-project-with-the-dependencies\">\uc885\uc18d\uc131\uc774 \uc788\ub294 \ud504\ub85c\uc81d\ud2b8 \ub9cc\ub4e4\uae30<\/h3>\n<p>\uba3c\uc800 \uc0c8 Node.js \ud504\ub85c\uc81d\ud2b8\ub97c \ub9cc\ub4e4\uace0 \ud544\uc694\ud55c \ubaa8\ub4e0 \ud504\ub85c\uc81d\ud2b8 \uc885\uc18d\uc131\uc744 \uc124\uce58\ud574 \ubcf4\uaca0\uc2b5\ub2c8\ub2e4. \ud130\ubbf8\ub110(Mac \ubc0f Linux) \ub610\ub294 \uba85\ub839 \ud504\ub86c\ud504\ud2b8(Windows)\uc5d0\uc11c \ub2e4\uc74c\uc744 \uc2e4\ud589\ud569\ub2c8\ub2e4:<\/p>\n<pre><code>npm init --y<\/code><\/pre>\n<p>\uc704\uc758 \uba85\ub839\uc740 \uc0c8 <strong>package.json<\/strong> \ud30c\uc77c\uc744 \ub9cc\ub4ed\ub2c8\ub2e4. \uc774 \ud30c\uc77c\uc5d0\ub294 \ubaa8\ub4e0 \uc885\uc18d\uc131 \uc815\ubcf4\uc640 \ub2e4\ub978 \uac83\ub4e4\uc774 \uc800\uc7a5\ub429\ub2c8\ub2e4.<\/p>\n<p>\uc774\uc81c \ud504\ub85c\uc81d\ud2b8\uc5d0 \ud544\uc694\ud55c \uac01 \uc885\uc18d \uc694\uc18c\ub97c \uc124\uce58\ud574\uc57c \ud569\ub2c8\ub2e4:<\/p>\n<pre><code>\uc5d4\ud53c\uc5e0 \uc124\uce58 \uce74\uc6b0\uce58\ubca0\uc774\uc2a4 \uc775\uc2a4\ud504\ub808\uc2a4 \uc624\uc2a4\ub9cc \ubc14\ub514-\ud30c\uc11c \ud574\uc2dc\ub4dc --save<\/code><\/pre>\n<p>\uc704\uc758 \uba85\ub839\uc740 HTTP \uc694\uccad\uc5d0\uc11c \ubcf8\ubb38 \ub370\uc774\ud130\ub97c \ubc1b\uc544\ub4e4\uc774\uae30 \uc704\ud55c Couchbase SDK, Express \ud504\ub808\uc784\uc6cc\ud06c, Ottoman, \ud574\uc2dc\ub4dc \ubc0f \ubcf8\ubb38 \ud30c\uc11c \ub77c\uc774\ube0c\ub7ec\ub9ac\ub97c \uc124\uce58\ud569\ub2c8\ub2e4.<\/p>\n<p>\uc774 \uc2dc\uc810\uc5d0\uc11c \uc560\ud50c\ub9ac\ucf00\uc774\uc158 \ubd80\ud2b8\uc2a4\ud2b8\ub7a9\uc744 \uc2dc\uc791\ud558\uc5ec \ubb34\uac70\uc6b4 \uc791\uc5c5\uc744 \uc218\ud589\ud560 \uc218 \uc788\ub3c4\ub85d \uc900\ube44\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<h3 id=\"bootstrapping-the-application\">\uc560\ud50c\ub9ac\ucf00\uc774\uc158 \ubd80\ud2b8\uc2a4\ud2b8\ub7a9<\/h3>\n<p>\uac04\ub2e8\ud558\uac8c \ud558\uae30 \uc704\ud574 \ubaa8\ub4e0 \uc560\ud50c\ub9ac\ucf00\uc774\uc158 \ucf54\ub4dc\ub294 \ud504\ub85c\uc81d\ud2b8 \ub0b4 \ub2e4\uc74c\uacfc \uac19\uc740 \ub2e8\uc77c \ud30c\uc77c\uc5d0 \uc800\uc7a5\ub429\ub2c8\ub2e4. <strong>index.js<\/strong>. \ud504\ub85c\ub355\uc158 \ud658\uacbd\uc5d0\uc11c\ub294 \uc720\uc9c0 \uad00\ub9ac \ud3b8\uc758\uc131\uc744 \uc704\ud574 \ubd84\ud560\ud558\ub294 \uac83\uc774 \uc88b\uaca0\uc9c0\ub9cc \uc774 \uac04\ub2e8\ud55c \uc608\uc81c\uc5d0\uc11c\ub294 \uad1c\ucc2e\uc744 \uac83\uc785\ub2c8\ub2e4.<\/p>\n<p>\uc5f4\uae30 <strong>index.js<\/strong> \ud30c\uc77c\uc744 \uc5f4\uace0 \uc124\uce58\ud55c \uac01 \uc885\uc18d\uc131\uc5d0 \ub300\ud55c \uac00\uc838\uc624\uae30\ub97c \ud3ec\ud568\ud558\uc138\uc694:<\/p>\n<pre><code>var Couchbase = require(\"couchbase\");\r\nvar Ottoman = require(\"ottoman\");\r\nvar Express = require(\"express\");\r\nvar BodyParser = require(\"body-parser\");\r\nvar Hashids = require(\"hashids\");<\/code><\/pre>\n<p>\uc885\uc18d\uc131\uc744 \uac00\uc838\uc628 \ud6c4\uc5d0\ub294 \uc774\uc81c \uc560\ud50c\ub9ac\ucf00\uc774\uc158 \ub0b4\uc5d0\uc11c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub3c4\ub85d \uc885\uc18d\uc131\uc744 \ucd08\uae30\ud654\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4:<\/p>\n<pre><code>var app = Express();\r\n\r\napp.use(BodyParser.json());\r\napp.use(BodyParser.urlencoded({ extended: true }));<\/code><\/pre>\n<p>\uc704\uc5d0\uc11c\ub294 \uae30\ubcf8\uc801\uc73c\ub85c Express \ud504\ub808\uc784\uc6cc\ud06c\ub97c \ucd08\uae30\ud654\ud558\uace0 \uc694\uccad\uc5d0\uc11c JSON \ubc0f URL\ub85c \uc778\ucf54\ub529\ub41c \ubcf8\ubb38 \ub370\uc774\ud130\ub97c \ubc1b\uc544\ub4e4\uc774\uace0 \uc2f6\ub2e4\uace0 \ub9d0\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p>\uc774 \uc2dc\uc810\uc5d0\uc11c Couchbase \ud074\ub7ec\uc2a4\ud130\uc5d0 \uc5f0\uacb0\uc744 \uc124\uc815\ud558\uace0 \uc560\ud50c\ub9ac\ucf00\uc774\uc158 \ubc84\ud0b7\uc744 \uc5f4 \uc218 \uc788\uc2b5\ub2c8\ub2e4:<\/p>\n<pre><code>Ottoman.bucket = (new Couchbase.Cluster(\"couchbase:\/\/localhost\")).openBucket(\"example\");<\/code><\/pre>\n<p>Ottoman\uc744 \uc0ac\uc6a9\ud558\ub824\uba74 \ud2b9\uc815 \uc778\ub371\uc2a4\uac00 \uc874\uc7ac\ud574\uc57c \ud569\ub2c8\ub2e4. \ub2e4\ud589\ud788\ub3c4 \uc774\ub7ec\ud55c \uc778\ub371\uc2a4\uac00 \uc544\uc9c1 \uc874\uc7ac\ud558\uc9c0 \uc54a\ub294 \uacbd\uc6b0 Ottoman\uc5d0\uc11c \uc0dd\uc131\ud558\ub3c4\ub85d \ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc778\ub371\uc2a4\uac00 \uc874\uc7ac\ud55c\ub2e4\ub294 \uac83\uc774 \ud655\uc778\ub418\uba74 \uc560\ud50c\ub9ac\ucf00\uc774\uc158 \uc11c\ube44\uc2a4\ub97c \uc2dc\uc791\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre><code>Ottoman.ensureIndices(function(error) {\r\n    if(error) {\r\n        console.log(error);\r\n    }\r\n    var server = app.listen(3000, function() {\r\n        console.log(\"Listening on port %s...\", server.address().port);\r\n    });\r\n});<\/code><\/pre>\n<p>\uc774 \uc608\uc81c\uc5d0\uc11c\ub294 \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc774 \ud3ec\ud2b8 3000\uc5d0\uc11c \ub85c\uceec\ub85c \uc11c\ube44\uc2a4\ub429\ub2c8\ub2e4.<\/p>\n<p>\uc9c0\uae08\uae4c\uc9c0\ub294 URL \ub2e8\ucd95\uae30 \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \uc704\ud55c \uae30\ubcf8 \ud504\ub808\uc784\uc6cc\ud06c\ub9cc \uc2e4\ud589\ud558\uace0 \uc788\uc5c8\uc2b5\ub2c8\ub2e4. \uc2e4\uc81c\ub85c CRUD \ub610\ub294 \ucffc\ub9ac \uc791\uc5c5\uacfc \uad00\ub828\ud558\uc5ec \ucd95\uc18c \ub85c\uc9c1\uc774\ub098 \ub370\uc774\ud130\ubca0\uc774\uc2a4\uc640\uc758 \uc0c1\ud638 \uc791\uc6a9\uc774 \uc5c6\uc2b5\ub2c8\ub2e4.<\/p>\n<h3 id=\"creating-the-data-model\">\ub370\uc774\ud130 \ubaa8\ub378 \ub9cc\ub4e4\uae30<\/h3>\n<p>\ub370\uc774\ud130\uac00 \ub370\uc774\ud130\ubca0\uc774\uc2a4\uc5d0\uc11c \uc5b4\ub5bb\uac8c \ubcf4\uc77c\uc9c0\ub294 \uc54c\uc9c0\ub9cc \uc544\uc9c1 \uc5b4\ub5bb\uac8c \uc0dd\uc131\ud560\uc9c0\ub294 \ubaa8\ub985\ub2c8\ub2e4. N1QL \ucffc\ub9ac\uac00 \uc544\ub2cc ODM\uc744 \uc0ac\uc6a9\ud558\ubbc0\ub85c \ucf54\ub4dc \ub0b4\uc5d0\uc11c \ubaa8\ub378\uc744 \uc815\uc758\ud574\uc57c \ud569\ub2c8\ub2e4.<\/p>\n<p>\uc774 \ud2b9\uc815 \ud504\ub85c\uc81d\ud2b8\uc5d0\uc11c \ubaa8\ub378\uc740 \ub9e4\uc6b0 \ub2e8\uc21c\ud569\ub2c8\ub2e4. \ub2e4\uc74c\uacfc \uac19\uc774 \ubcf4\uc77c \uac83\uc785\ub2c8\ub2e4:<\/p>\n<pre><code>var UrlModel = Ottoman.model(\"Url\", {\r\n    hash: {type: \"string\", readonly: true},\r\n    longUrl: \"string\",\r\n    shortUrl: \"string\"\r\n}, {\r\n    id: \"hash\"\r\n});<\/code><\/pre>\n<p>\uc704\uc758 \ub370\uc774\ud130 \ubaa8\ub378\uc5d0\uc11c \uc6b0\ub9ac\ub294 <code>Url<\/code>\uc5d0\ub294 \uc138 \uac00\uc9c0 \uc18d\uc131\uc774 \uc788\uc2b5\ub2c8\ub2e4. The <code>\ud574\uc2dc<\/code> \uc18d\uc131\uc740 \ubb38\uc11c ID\ub97c \ub098\ud0c0\ub0c5\ub2c8\ub2e4. \ubb38\uc11c ID\ub97c \uc218\ub3d9\uc73c\ub85c \uc124\uc815\ud560 \ud544\uc694\ub294 \uc5c6\uc9c0\ub9cc \uc774 \ud504\ub85c\uc81d\ud2b8\uc5d0\uc11c\ub294 \uc218\ub3d9\uc73c\ub85c \uc124\uc815\ud558\ub294 \uac83\uc774 \uc88b\uc2b5\ub2c8\ub2e4. \ubb38\uc11c ID\ub97c \uc218\ub3d9\uc73c\ub85c \uc124\uc815\ud558\ub824\uba74 \ud574\ub2f9 \ud504\ub85c\ud37c\ud2f0\uac00 \uc77d\uae30 \uc804\uc6a9\uc774\uc5b4\uc57c \ud569\ub2c8\ub2e4. \ub098\uba38\uc9c0 \ub450 \uc18d\uc131\uc740 \ud45c\uc900 \ubb38\uc790\uc5f4 \uac12\uc785\ub2c8\ub2e4.<\/p>\n<p>\uc774 \ubaa8\ub378\uc740 \ud544\uc694\uc5d0 \ub530\ub77c \ubb34\ud55c\ud788 \ub354 \ubcf5\uc7a1\ud574\uc9c8 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<h3 id=\"applying-the-data-model-in-a-series-of-restful-endpoint-methods\">\uc77c\ub828\uc758 RESTful \uc5d4\ub4dc\ud3ec\uc778\ud2b8 \uba54\uc11c\ub4dc\uc5d0\uc11c \ub370\uc774\ud130 \ubaa8\ub378 \uc801\uc6a9\ud558\uae30<\/h3>\n<p>\uc6b0\ub9ac\uac00 \uad6c\ucd95\ud558\ub294 \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc740 RESTful \uc6f9 \uc11c\ube44\uc2a4\uc774\ubbc0\ub85c \uba87 \uac00\uc9c0 \uc5d4\ub4dc\ud3ec\uc778\ud2b8 \ud568\uc218\ub97c \ub9cc\ub4e4\uc5b4\uc57c \ud569\ub2c8\ub2e4. \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc5d0\ub294 \ub2e4\uc74c \uc138 \uac00\uc9c0 \uacf5\uc6a9 \uc5d4\ub4dc\ud3ec\uc778\ud2b8\uac00 \ud3ec\ud568\ub429\ub2c8\ub2e4:<\/p>\n<pre><code>\/\r\n\/create\r\n\/expand<\/code><\/pre>\n<p>\uc5b8\uc81c <strong>root<\/strong> \uc5d4\ub4dc\ud3ec\uc778\ud2b8\uc5d0 \ub3c4\ub2ec\ud558\uba74 \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc774 Couchbase\uc5d0 \uc800\uc7a5\ub41c \uae34 URL\ub85c \uc774\ub3d9\ud569\ub2c8\ub2e4. \uc774 \ub54c <strong>\/\uc0dd\uc131<\/strong> \uc5d4\ub4dc\ud3ec\uc778\ud2b8\uc5d0 \ub3c4\ub2ec\ud558\uba74 \uc774\uc804\uc5d0 \uc800\uc7a5\ub41c \uc9e7\uc740 URL\uc744 \ucc3e\uac70\ub098 \uc874\uc7ac\ud558\uc9c0 \uc54a\ub294 \uacbd\uc6b0 \uc0c8\ub85c \ub9cc\ub4e4\ub824\uace0 \uc2dc\ub3c4\ud569\ub2c8\ub2e4. \uc774\ub807\uac8c \ud558\ub294 \uc774\uc720\ub294 \uae34 URL\uc758 \ubcf5\uc0ac\ubcf8\uc744 \uc5ec\ub7ec \uac1c \uc800\uc7a5\ud558\uace0 \uc2f6\uc9c0 \uc54a\uae30 \ub54c\ubb38\uc785\ub2c8\ub2e4. \ub9c8\uc9c0\ub9c9\uc73c\ub85c <strong>\/\ud655\uc7a5<\/strong> \uc5d4\ub4dc\ud3ec\uc778\ud2b8\ub97c \ucd94\uac00\ud558\uc5ec \uc9e7\uc740 URL\uc774 \uc5b4\ub514\ub85c \uc774\ub3d9\ud558\ub294\uc9c0 \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p>\ubd80\ud130 \uc2dc\uc791\ud558\uc5ec <strong>\/\uc0dd\uc131<\/strong> \uc5d4\ub4dc\ud3ec\uc778\ud2b8\uc5d0\uc11c \uac00\uc7a5 \ubcf5\uc7a1\ud55c \ubd80\ubd84\uc778 \ub2e4\uc74c\uacfc \uac19\uc740 \uba54\uc11c\ub4dc\uac00 \uc788\uc2b5\ub2c8\ub2e4:<\/p>\n<pre><code>app.post(\"\/create\", function(req, res) {\r\n    if(!req.body.longUrl) {\r\n        return res.status(400).send({\"status\": \"error\", \"message\": \"A long URL is required\"});\r\n    }\r\n    UrlModel.find({\"longUrl\": req.body.longUrl}, function(error, url) {\r\n        if(error) {\r\n            return res.status(400).send(error);\r\n        }\r\n        if(url.length == 0) {\r\n            var hashids = new Hashids();\r\n            var urlObj = new UrlModel({\r\n                hash: hashids.encode((new Date).getTime()),\r\n                longUrl: req.body.longUrl\r\n            });\r\n            urlObj.shortUrl = \"https:\/\/localhost:3000\/\" + urlObj.hash;\r\n            urlObj.save(function(error, result) {\r\n                if(error) {\r\n                    return res.status(400).send(error);\r\n                }\r\n                res.send(urlObj);\r\n            });\r\n        } else {\r\n            res.send(url[0]);\r\n        }\r\n    });\r\n});<\/code><\/pre>\n<p>\uc704\uc758 \uc5d4\ub4dc\ud3ec\uc778\ud2b8\ub294 \ubcf8\ubb38\uc744 \uae30\ub300\ud558\ub294 POST \uc694\uccad \uc5d4\ub4dc\ud3ec\uc778\ud2b8\uc785\ub2c8\ub2e4. \ubcf8\ubb38\uc5d0\uc11c \uae34 URL\uc744 \ucc3e\uc744 \uc218 \uc5c6\uc73c\uba74 \uc624\ub958\uac00 \ubc18\ud658\ub429\ub2c8\ub2e4. \uadf8\ub807\uc9c0 \uc54a\uc73c\uba74 \uc81c\uacf5\ub41c \uae34 URL\uc744 \uae30\ubc18\uc73c\ub85c Ottoman \uc870\ud68c\uac00 \uc218\ud589\ub429\ub2c8\ub2e4. \uc870\ud68c\uc5d0\uc11c \ub370\uc774\ud130\uac00 \ubc1c\uacac\ub418\uba74 \ud574\ub2f9 \ub370\uc774\ud130\uac00 \uc0ac\uc6a9\uc790\uc5d0\uac8c \ubc18\ud658\ub418\uace0, \uadf8\ub807\uc9c0 \uc54a\uc73c\uba74 \uc0c8 \ud56d\ubaa9 \uc0dd\uc131\uc744 \uc704\ud55c \ud504\ub85c\uc138\uc2a4\uac00 \uc2dc\uc791\ub429\ub2c8\ub2e4.<\/p>\n<p>\uc0c8 \ud56d\ubaa9\uc744 \ub9cc\ub4dc\ub294 \ub3d9\uc548 \ud0c0\uc784\uc2a4\ud0ec\ud504\ub97c \uae30\ubc18\uc73c\ub85c \uace0\uc720\ud55c \ud574\uc2dc\uac00 \uc0dd\uc131\ub429\ub2c8\ub2e4. \uc774 \ud574\uc2dc\ub294 \uc9e7\uc740 \ud638\uc2a4\ud2b8 \uc774\ub984\uc5d0 \ucd94\uac00\ub418\uace0 \ud574\uc2dc \uc790\uccb4 \ubc0f \uae34 URL\uacfc \ud568\uaed8 \ub370\uc774\ud130\ubca0\uc774\uc2a4\uc5d0 \uc800\uc7a5\ub429\ub2c8\ub2e4. \uc800\uc7a5\uc5d0 \uc131\uacf5\ud558\uba74 \uac1c\uccb4\uac00 \ubc18\ud658\ub429\ub2c8\ub2e4.<\/p>\n<p>\ub2e4\uc74c\uacfc \uac19\uc740 \uacbd\uc6b0 <strong>\/\ud655\uc7a5<\/strong> \uc5d4\ub4dc\ud3ec\uc778\ud2b8\uc5d0\ub294 \ub2e4\uc74c\uc774 \uc788\uc2b5\ub2c8\ub2e4:<\/p>\n<pre><code>app.get(\"\/expand\", function(req, res) {\r\n    if(!req.query.shortUrl) {\r\n        return res.status(400).send({\"status\": \"error\", \"message\": \"A short URL is required\"});\r\n    }\r\n    UrlModel.find({\"shortUrl\": req.query.shortUrl}, function(error, url) {\r\n        if(error) {\r\n            return res.status(400).send(error);\r\n        }\r\n        res.send(url.length &gt; 0 ? url[0] : {});\r\n    });\r\n});<\/code><\/pre>\n<p>\uc774 \ubc29\ubc95\uc740 \ub2e4\uc74c\uacfc \uc720\uc0ac\ud569\ub2c8\ub2e4. <strong>\/\uc0dd\uc131<\/strong> \uc5d4\ub4dc\ud3ec\uc778\ud2b8\uc640 \ube44\uc2b7\ud558\uc9c0\ub9cc \uc644\uc804\ud788 \ub3d9\uc77c\ud558\uc9c0\ub294 \uc54a\uc2b5\ub2c8\ub2e4. \ub300\uc2e0 \uc81c\uacf5\ub41c \uc9e7\uc740 URL\uc744 \uae30\ubc18\uc73c\ub85c \uc870\ud68c\ub97c \uc218\ud589\ud569\ub2c8\ub2e4. \ucc3e\uc73c\uba74 \uae34 URL\uc774 \ud3ec\ud568\ub41c \ubb38\uc11c\ub97c \ubc18\ud658\ud558\uace0, \uadf8\ub807\uc9c0 \uc54a\uc73c\uba74 \ube48 \uac1d\uccb4\ub97c \ubc18\ud658\ud569\ub2c8\ub2e4.<\/p>\n<p>\ub9c8\uc9c0\ub9c9\uc73c\ub85c <strong>root<\/strong> \uc5d4\ub4dc\ud3ec\uc778\ud2b8. \uc774 \uc5d4\ub4dc\ud3ec\uc778\ud2b8\ub294 \uae34 URL\ub85c\uc758 \ub9ac\ub514\ub809\uc158\uc744 \ub2f4\ub2f9\ud558\uba70 \uc2e4\uc81c\ub85c\ub294 \ud574\uc2dc\uc778 ID\uac00 \ud544\uc694\ud569\ub2c8\ub2e4. \ub3d9\uc77c\ud55c \uc11c\ubc84\uc5d0\uc11c API\uc640 \uc9e7\uc740 URL\uc744 \ud638\uc2a4\ud305\ud558\uace0 \uc788\ub2e4\ub294 \uc810\uc744 \uae30\uc5b5\ud558\uc138\uc694.<\/p>\n<pre><code>app.get(\"\/:id\", function(req, res) {\r\n    if(!req.params.id) {\r\n        return res.status(400).send({\"status\": \"error\", \"message\": \"An id is required\"});\r\n    }\r\n    UrlModel.getById(req.params.id, function(error, url) {\r\n        if(error) {\r\n            return res.status(400).send(error);\r\n        }\r\n        res.redirect(url.longUrl);\r\n    });\r\n});<\/code><\/pre>\n<p>\ub530\ub77c\uc11c \ub2e4\uc74c\uacfc \uac19\uc774 \uc774\ub3d9\ud55c\ub2e4\uace0 \uac00\uc815\ud574 \ubcf4\uaca0\uc2b5\ub2c8\ub2e4. <strong>https:\/\/localhost:3000\/2xmx9qpyj<\/strong> \ub97c \ud074\ub9ad\ud569\ub2c8\ub2e4. \ube0c\ub77c\uc6b0\uc800\uc758 <strong>2xmx9qpyj<\/strong> \ub294 \ud574\uc2dc\uac12\uc774\uae30\ub3c4 \ud55c ID\uc785\ub2c8\ub2e4. \uc774 ID\ub97c \uae30\ubc18\uc73c\ub85c \ubb38\uc11c\ub97c \uc870\ud68c\ud558\uace0 \ubb38\uc11c\uac00 \uc788\ub294\uc9c0 \ud0d0\uc0c9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p>\ub098\uc058\uc9c0 \uc54a\uc8e0?<\/p>\n<h3 id=\"the-full-application-source-code\">\uc804\uccb4 \uc560\ud50c\ub9ac\ucf00\uc774\uc158 \uc18c\uc2a4 \ucf54\ub4dc<\/h3>\n<p>\uc804\uccb4 \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \ud55c \ub208\uc5d0 \ubcf4\uace0 \uc2f6\ub2e4\uba74 \uc544\ub798\uc5d0\uc11c \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre><code>var Couchbase = require(\"couchbase\");\r\nvar Ottoman = require(\"ottoman\");\r\nvar Express = require(\"express\");\r\nvar BodyParser = require(\"body-parser\");\r\nvar Hashids = require(\"hashids\");\r\n\r\nvar app = Express();\r\n\r\napp.use(BodyParser.json());\r\napp.use(BodyParser.urlencoded({ extended: true }));\r\n\r\nOttoman.bucket = (new Couchbase.Cluster(\"couchbase:\/\/localhost\")).openBucket(\"example\");\r\n\r\nvar UrlModel = Ottoman.model(\"Url\", {\r\n    hash: {type: \"string\", readonly: true},\r\n    longUrl: \"string\",\r\n    shortUrl: \"string\"\r\n}, {\r\n    id: \"hash\"\r\n});\r\n\r\napp.get(\"\/expand\", function(req, res) {\r\n    if(!req.query.shortUrl) {\r\n        return res.status(400).send({\"status\": \"error\", \"message\": \"A short URL is required\"});\r\n    }\r\n    UrlModel.find({\"shortUrl\": req.query.shortUrl}, function(error, url) {\r\n        if(error) {\r\n            return res.status(400).send(error);\r\n        }\r\n        res.send(url.length &gt; 0 ? url[0] : {});\r\n    });\r\n});\r\n\r\napp.post(\"\/create\", function(req, res) {\r\n    if(!req.body.longUrl) {\r\n        return res.status(400).send({\"status\": \"error\", \"message\": \"A long URL is required\"});\r\n    }\r\n    UrlModel.find({\"longUrl\": req.body.longUrl}, function(error, url) {\r\n        if(error) {\r\n            return res.status(400).send(error);\r\n        }\r\n        if(url.length == 0) {\r\n            var hashids = new Hashids();\r\n            var urlObj = new UrlModel({\r\n                hash: hashids.encode((new Date).getTime()),\r\n                longUrl: req.body.longUrl\r\n            });\r\n            urlObj.shortUrl = \"https:\/\/localhost:3000\/\" + urlObj.hash;\r\n            urlObj.save(function(error, result) {\r\n                if(error) {\r\n                    return res.status(400).send(error);\r\n                }\r\n                res.send(urlObj);\r\n            });\r\n        } else {\r\n            res.send(url[0]);\r\n        }\r\n    });\r\n});\r\n\r\napp.get(\"\/:id\", function(req, res) {\r\n    if(!req.params.id) {\r\n        return res.status(400).send({\"status\": \"error\", \"message\": \"An id is required\"});\r\n    }\r\n    UrlModel.getById(req.params.id, function(error, url) {\r\n        if(error) {\r\n            return res.status(400).send(error);\r\n        }\r\n        res.redirect(url.longUrl);\r\n    });\r\n});\r\n\r\nOttoman.ensureIndices(function(error) {\r\n    if(error) {\r\n        console.log(error);\r\n    }\r\n    var server = app.listen(3000, function() {\r\n        console.log(\"Listening on port %s...\", server.address().port);\r\n    });\r\n});<\/code><\/pre>\n<p>\uc704\uc758 \ucf54\ub4dc\ub97c \ub2e4\uc74c\uacfc \uac19\uc774 \uc2e4\ud589\ud558\uba74 <code>npm index.js<\/code> \uc5d0 \uc788\ub294 \uac01 API \uc5d4\ub4dc\ud3ec\uc778\ud2b8\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. <strong>https:\/\/localhost:3000<\/strong>.<\/p>\n<h2 id=\"conclusion\">\uacb0\ub860<\/h2>\n<p>\ubc29\uae08 Ottoman, Couchbase Server \ubc0f Node.js\ub77c\ub294 \uac1d\uccb4 \ubb38\uc11c \ubaa8\ub378(ODM)\uc744 \uc0ac\uc6a9\ud558\uc5ec URL \ub2e8\ucd95\uae30 \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \ub9cc\ub4dc\ub294 \ubc29\ubc95\uc744 \uc0b4\ud3b4\ubd24\uc2b5\ub2c8\ub2e4. ODM\uc744 \uc88b\uc544\ud558\uc9c0 \uc54a\uac70\ub098 SQL \ucffc\ub9ac\ub97c \uc0ac\uc6a9\ud558\uc5ec \uc774 \uc791\uc5c5\uc744 \uc218\ud589\ud558\ub294 \ubc29\ubc95\uc744 \ud655\uc778\ud558\ub824\ub294 \uacbd\uc6b0 <a href=\"https:\/\/www.couchbase.com\/blog\/ko\/create-a-url-shortener-with-nodejs-and-couchbase-using-n1ql\/\">\uc774\uc804 \ud29c\ud1a0\ub9ac\uc5bc<\/a> \uc774 \uc8fc\uc81c\uc5d0 \ub300\ud574 \uae00\uc744 \uc37c\uc2b5\ub2c8\ub2e4.<\/p>\n<p>\uc774 \ud29c\ud1a0\ub9ac\uc5bc\uc744 \ud55c \ub2e8\uacc4 \ub354 \ubc1c\uc804\uc2dc\ud0a4\uace0 \uc2f6\uc73c\uc2e0\uac00\uc694? \uc9e7\uc740 URL\uc744 \uc0ac\uc6a9\ud558\ub824\ub294 \uc0ac\ub78c\ub4e4\ub85c\ubd80\ud130 \ubd84\uc11d \uc815\ubcf4\ub97c \uc218\uc9d1\ud574 \ubcf4\uc138\uc694. \ud0d0\uc0c9 \uc804\uc5d0 \ubb38\uc11c \ub0b4\ubd80\uc5d0 \ud788\ud2b8 \uce74\uc6b4\ud130\ub97c \uc720\uc9c0\ud558\uac70\ub098 \ube0c\ub77c\uc6b0\uc800 \uc0ac\uc6a9\uc790 \uc5d0\uc774\uc804\ud2b8\uc640 \uac19\uc740 \uc815\ubcf4\ub97c \uc800\uc7a5\ud560 \uc218\ub3c4 \uc788\uc2b5\ub2c8\ub2e4.<\/p>","protected":false},"excerpt":{"rendered":"<p>Not too long ago I wrote about creating a URL shortener with Node.js and Couchbase N1QL. If you haven&#8217;t already seen it, the article is a great introduction to Couchbase and creating RESTful APIs using Node.js and Express Framework. The [&hellip;]<\/p>","protected":false},"author":63,"featured_media":13873,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1815,1822,10128],"tags":[1510,1768,1767],"ppma_author":[9032],"class_list":["post-2448","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-best-practices-and-tutorials","category-node-js","category-ottoman","tag-odm","tag-short-hash","tag-url-shortener"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>URL Shortener using Ottoman ODM with Node.js &amp; Couchbase<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/ko\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create a URL Shortener using Ottoman ODM with Node.js and Couchbase\" \/>\n<meta property=\"og:description\" content=\"Not too long ago I wrote about creating a URL shortener with Node.js and Couchbase N1QL. If you haven&#8217;t already seen it, the article is a great introduction to Couchbase and creating RESTful APIs using Node.js and Express Framework. The [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/ko\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/thepolyglotdeveloper\" \/>\n<meta property=\"article:published_time\" content=\"2016-12-20T15:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T04:40:24+00:00\" \/>\n<meta name=\"author\" content=\"Nic Raboy, Developer Advocate, Couchbase\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@nraboy\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nic Raboy, Developer Advocate, Couchbase\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/\"},\"author\":{\"name\":\"Nic Raboy, Developer Advocate, Couchbase\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1\"},\"headline\":\"Create a URL Shortener using Ottoman ODM with Node.js and Couchbase\",\"datePublished\":\"2016-12-20T15:00:00+00:00\",\"dateModified\":\"2025-06-14T04:40:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/\"},\"wordCount\":1363,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"keywords\":[\"odm\",\"short hash\",\"url shortener\"],\"articleSection\":[\"Best Practices and Tutorials\",\"Node.js\",\"Ottoman.js ODM\"],\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/\",\"name\":\"URL Shortener using Ottoman ODM with Node.js & Couchbase\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"datePublished\":\"2016-12-20T15:00:00+00:00\",\"dateModified\":\"2025-06-14T04:40:24+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"width\":1800,\"height\":630},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create a URL Shortener using Ottoman ODM with Node.js and Couchbase\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1\",\"name\":\"Nic Raboy, Developer Advocate, Couchbase\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/8863514d8bed0cf6080f23db40e00354\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g\",\"caption\":\"Nic Raboy, Developer Advocate, Couchbase\"},\"description\":\"Nic Raboy is an advocate of modern web and mobile development technologies. He has experience in Java, JavaScript, Golang and a variety of frameworks such as Angular, NativeScript, and Apache Cordova. Nic writes about his development experiences related to making web and mobile development easier to understand.\",\"sameAs\":[\"https:\/\/www.thepolyglotdeveloper.com\",\"https:\/\/www.facebook.com\/thepolyglotdeveloper\",\"https:\/\/x.com\/nraboy\"],\"url\":\"https:\/\/www.couchbase.com\/blog\/ko\/author\/nic-raboy-2\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"URL Shortener using Ottoman ODM with Node.js & Couchbase","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/ko\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/","og_locale":"ko_KR","og_type":"article","og_title":"Create a URL Shortener using Ottoman ODM with Node.js and Couchbase","og_description":"Not too long ago I wrote about creating a URL shortener with Node.js and Couchbase N1QL. If you haven&#8217;t already seen it, the article is a great introduction to Couchbase and creating RESTful APIs using Node.js and Express Framework. The [&hellip;]","og_url":"https:\/\/www.couchbase.com\/blog\/ko\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/","og_site_name":"The Couchbase Blog","article_author":"https:\/\/www.facebook.com\/thepolyglotdeveloper","article_published_time":"2016-12-20T15:00:00+00:00","article_modified_time":"2025-06-14T04:40:24+00:00","author":"Nic Raboy, Developer Advocate, Couchbase","twitter_card":"summary_large_image","twitter_creator":"@nraboy","twitter_misc":{"Written by":"Nic Raboy, Developer Advocate, Couchbase","Est. reading time":"8\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/"},"author":{"name":"Nic Raboy, Developer Advocate, Couchbase","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1"},"headline":"Create a URL Shortener using Ottoman ODM with Node.js and Couchbase","datePublished":"2016-12-20T15:00:00+00:00","dateModified":"2025-06-14T04:40:24+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/"},"wordCount":1363,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","keywords":["odm","short hash","url shortener"],"articleSection":["Best Practices and Tutorials","Node.js","Ottoman.js ODM"],"inLanguage":"ko-KR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/","url":"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/","name":"URL Shortener using Ottoman ODM with Node.js & Couchbase","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","datePublished":"2016-12-20T15:00:00+00:00","dateModified":"2025-06-14T04:40:24+00:00","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/"]}]},{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","width":1800,"height":630},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/create-a-url-shortener-using-ottoman-odm-with-nodejs-and-couchbase\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Create a URL Shortener using Ottoman ODM with Node.js and Couchbase"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"\uce74\uc6b0\uce58\ubca0\uc774\uc2a4 \ube14\ub85c\uadf8","description":"NoSQL \ub370\uc774\ud130\ubca0\uc774\uc2a4, Couchbase","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"\uce74\uc6b0\uce58\ubca0\uc774\uc2a4 \ube14\ub85c\uadf8","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1","name":"Nic Raboy, \uac1c\ubc1c\uc790 \uc639\ud638\uc790, Couchbase","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/8863514d8bed0cf6080f23db40e00354","url":"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g","caption":"Nic Raboy, Developer Advocate, Couchbase"},"description":"\ub2c9 \ub77c\ubcf4\uc774\ub294 \ucd5c\uc2e0 \uc6f9 \ubc0f \ubaa8\ubc14\uc77c \uac1c\ubc1c \uae30\uc220\uc744 \uc639\ud638\ud558\ub294 \uc0ac\ub78c\uc785\ub2c8\ub2e4. \uadf8\ub294 Java, JavaScript, Golang \ubc0f Angular, NativeScript, Apache Cordova\uc640 \uac19\uc740 \ub2e4\uc591\ud55c \ud504\ub808\uc784\uc6cc\ud06c\uc5d0 \ub300\ud55c \uacbd\ud5d8\uc774 \uc788\uc2b5\ub2c8\ub2e4. Nic\uc740 \uc6f9 \ubc0f \ubaa8\ubc14\uc77c \uac1c\ubc1c\uc744 \ubcf4\ub2e4 \uc27d\uac8c \uc774\ud574\ud560 \uc218 \uc788\ub3c4\ub85d \uc790\uc2e0\uc758 \uac1c\ubc1c \uacbd\ud5d8\uc5d0 \ub300\ud574 \uae00\uc744 \uc4f0\uace0 \uc788\uc2b5\ub2c8\ub2e4.","sameAs":["https:\/\/www.thepolyglotdeveloper.com","https:\/\/www.facebook.com\/thepolyglotdeveloper","https:\/\/x.com\/nraboy"],"url":"https:\/\/www.couchbase.com\/blog\/ko\/author\/nic-raboy-2\/"}]}},"authors":[{"term_id":9032,"user_id":63,"is_guest":0,"slug":"nic-raboy-2","display_name":"Nic Raboy, Developer Advocate, Couchbase","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g","author_category":"","last_name":"Raboy","first_name":"Nic","job_title":"","user_url":"https:\/\/www.thepolyglotdeveloper.com","description":"\ub2c9 \ub77c\ubcf4\uc774\ub294 \ucd5c\uc2e0 \uc6f9 \ubc0f \ubaa8\ubc14\uc77c \uac1c\ubc1c \uae30\uc220\uc744 \uc639\ud638\ud558\ub294 \uc0ac\ub78c\uc785\ub2c8\ub2e4. \uadf8\ub294 Java, JavaScript, Golang \ubc0f Angular, NativeScript, Apache Cordova\uc640 \uac19\uc740 \ub2e4\uc591\ud55c \ud504\ub808\uc784\uc6cc\ud06c\uc5d0 \ub300\ud55c \uacbd\ud5d8\uc774 \uc788\uc2b5\ub2c8\ub2e4. Nic\uc740 \uc6f9 \ubc0f \ubaa8\ubc14\uc77c \uac1c\ubc1c\uc744 \ubcf4\ub2e4 \uc27d\uac8c \uc774\ud574\ud560 \uc218 \uc788\ub3c4\ub85d \uc790\uc2e0\uc758 \uac1c\ubc1c \uacbd\ud5d8\uc5d0 \ub300\ud574 \uae00\uc744 \uc4f0\uace0 \uc788\uc2b5\ub2c8\ub2e4."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/posts\/2448","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/comments?post=2448"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/posts\/2448\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/media\/13873"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/media?parent=2448"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/categories?post=2448"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/tags?post=2448"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/ppma_author?post=2448"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}