{"id":22353208,"url":"https://github.com/joelseq/sdhacks-workshop","last_synced_at":"2026-02-02T20:02:05.354Z","repository":{"id":95218592,"uuid":"107756513","full_name":"joelseq/sdhacks-workshop","owner":"joelseq","description":"Starter Code for SD Hacks workshop","archived":false,"fork":false,"pushed_at":"2017-10-21T11:37:55.000Z","size":22,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-02T00:15:34.859Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","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/joelseq.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-10-21T06:18:28.000Z","updated_at":"2017-12-02T05:17:34.000Z","dependencies_parsed_at":"2023-06-02T00:37:47.453Z","dependency_job_id":null,"html_url":"https://github.com/joelseq/sdhacks-workshop","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/joelseq/sdhacks-workshop","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelseq%2Fsdhacks-workshop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelseq%2Fsdhacks-workshop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelseq%2Fsdhacks-workshop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelseq%2Fsdhacks-workshop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joelseq","download_url":"https://codeload.github.com/joelseq/sdhacks-workshop/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelseq%2Fsdhacks-workshop/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263426233,"owners_count":23464793,"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-12-04T12:34:40.374Z","updated_at":"2026-02-02T20:02:05.076Z","avatar_url":"https://github.com/joelseq.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SD Hacks WebDev Workshop Starter Code\n\n[Final Code Here](https://github.com/joelseq/sdhacks-workshop/tree/final)\n\n## Code Snippets\n\n### Get all posts\n\n```js\n// Find all the documents\ndb.allDocs({\n  include_docs: true,\n  attachments: true\n}, function(error, result) {\n  if(error) {\n    console.log(error);\n  } else {\n    res.render('posts', { posts: result.rows });\n  }\n});\n``` \n\n### Create a new post\n\n```js\nvar toSave = {\n  title: req.body.title,\n  post: req.body.post\n};\n\ndb.post(toSave, function(error, posted) {\n  if(error) {\n    console.log(error);\n  } else {\n    console.log(posted);\n  }\n  res.redirect('/');\n});\n```\n\n\n### Get a single post\n \n```js\ndb.get(req.params.id, function(error, found) {\n    if(error) {\n      console.log(error);\n      res.redirect('/');\n    } else {\n      res.render('show-post', { post: found });\n    }\n  });\n```\n\n### Edit a post\n\n```js\ndb.get(req.params.id, function(error, found) {\n  if(error) {\n    console.log(error);\n    res.redirect('/');\n  } else {\n    res.render('edit-post', { post: found });\n  }\n});\n```\n\n### Update a post\n\n```js\nvar toSave = {\n  title: req.body.title,\n  post: req.body.post\n};\n\ndb.get(req.params.id, function(error, found) {\n  if(error) {\n    console.log(error);\n    res.redirect('/');\n  } else {\n    db.put({\n      _id: found._id,\n      _rev: found._rev,\n      title: req.body.title,\n      post: req.body.post\n    }, function(error, saved) {\n      if(error) {\n        console.log(error);\n      }\n      res.redirect('/');\n    });\n  }\n});\n```\n\n### Delete a post\n\n```js\ndb.get(req.params.id, function(err, found) {\n  if(err) {\n    console.log(err);\n    res.redirect('/');\n  } else {\n    db.remove(found, function(err, removed) {\n      if(err) {\n        console.log(err);\n        res.redirect('/');\n      } else {\n        res.redirect('/');\n      }\n    });\n  }\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelseq%2Fsdhacks-workshop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoelseq%2Fsdhacks-workshop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelseq%2Fsdhacks-workshop/lists"}