Back to Question Center
0

Yadda za'a fara tare da restdb.io kuma Ƙirƙiri CMS mai sauki            Yadda za a fara tare da restdb.io da kuma Create a Simple CMSRelated Topics: Kayan aiki & Semalt ...

1 answers:
Yadda za'a fara tare da restdb. i da Ƙirƙiri Ƙarin CMS

Yadda za'a fara tare da restdb. i da Ƙirƙiri CMS mai saukiYadda za'a fara tare da restdb. io da Create a Simple CMSRelated Topics:
Kayayyakin & Tsare

Wannan batun ya tallafawa by restdb. i. Na gode don goyan bayan abokan hulɗa da suke yin SitePoint yiwu - valor curso de fotografia.

Bayanin bayanai sunyi tsoro cikin zuciyar masu ci gaba da ƙwarewa. Shigarwa, sabuntawa, tanadar sararin samaniya, sauye-sauye, daidaitaccen bincike, ƙayyadaddun tambayoyin, da ƙwarewa matsalolin da yawa zasu iya yi ba tare da. Ƙungiyoyi masu girma za su yi amfani da ƙwararrun masu ilimi wanda ke keɓe rayuwarsu ga rikice-rikice na bayanai. Duk da haka tsarin ba zai yiwu ba lokacin da suke hutu.

Wani zaɓi mafi inganci shi ne don fitar da bayanai ɗinka kuma wannan shine ainihin sabis ɗin restdb. amincin ya samar. Suna sarrafa shenanigans masu ajiyar bayanai, suna barin ku don mayar da hankalin akan ayyukan da ake ci gaba da gaggawa.

restdb. a: da Basics

restdb. io ne mai kunnawa da kuma yin amfani da girgije NoSQL bayanai. Nan da nan kowa zai san wanda yake tare da sanin MongoDB. Ƙananan bambance-bambancen:

  • Babu buƙatar gudanar da shigarwa, ajiya ko backups
  • zaka iya ƙayyade tsarin tsari na bayanai a restdb. i
  • filayen bayanai zasu iya samun dangantaka tare da sauran wurare a cikin sauran ɗakunan
  • Babu buƙatar ƙayyade alaƙa
  • Ana iya tambayar da sabunta bayanai ta hanyar REST API wanda aka tabbatar ta hanyar HTTP ko Auth0 / JWT
  • Ana aika tambayoyin da sabuntawa a cikin tsarin JSON
  • Akwai kayan aiki don shigarwa, dubawa da fitarwa bayanai a wasu nau'i-nau'i
  • yana tallafa wa wasu siffofi masu kayatarwa masu ban sha'awa irin su codehooks, imel, shafukan yanar gizo, shafukan intanit, saƙonni na ainihi, da sauransu.

Asusun kyauta yana ba ka izinin sabis ɗin ba tare da wajibi ba. Shirye-shiryen da aka ba da ƙarin ƙarin ajiyar wuri, tambayoyin da aka samo, kayan haɓakawa da kuma haɗin shiga MongoDB.

A cikin wadannan sassan zan bayyana yadda za:

  1. saita wani sabon database kuma shigar da bayanai
  2. yi amfani da wannan bayanan don sanya shafin yanar gizon da aka shirya a restdb. io, da
  3. yi amfani da API don samar da kayan bincike don masu gyara abun ciki.

Mataki na 1: Ƙirƙirar Sabon Bayanan

Bayan shiga tare da Google, Facebook ko asusun imel, za ka iya ƙirƙirar wani sabon asusun banza. Wannan yana haifar da sabon adireshin ƙarshe API a yourdbname . restdb. i:

Yadda za'a fara tare da restdb. i da Ƙirƙiri CMS mai saukiYadda za'a fara tare da restdb. io da Create a Simple CMSRelated Topics:
Kayayyakin & Tsare

Mataki na 2: Samar da Sabon Tambaya

Cibiyar sadarwa ta ƙunshi ɗaya ko fiye tarin don adana bayanai. Waɗannan su ne analogous zuwa Tables na SQL. Collections dauke da "takardun" wanda suke analogous zuwa SQL database records (layuka layuka).

Sauran. In na dubawa yana samar da hanyoyi guda biyu:

  1. Yanayin daidaitattun nuna samfuran da aka samo kuma ba ka damar sakawa da kuma gyara bayanai.
  2. Yanayin Developer ba ka damar ƙirƙirar da kuma saita tarin.

Yadda za'a fara tare da restdb. i da Ƙirƙiri CMS mai saukiYadda za'a fara tare da restdb. io da Create a Simple CMSRelated Topics:
Kayayyakin & Tsare

Shigar da Mode Developer (saman dama na allon) kuma danna maɓalli Ƙarin Ƙari .

Tarin yana buƙatar suna na musamman (Na yi amfani da "abun ciki") da kuma bayanin zaɓi da icon. Hit Ajiye don komawa bayanan bayanan yanar gizonku. Ƙungiyar "abun ciki" za ta bayyana a cikin jerin tare da wasu sauran abubuwan da ba a yarda ba.

A madadin, ana iya shigo da bayanai daga fayilolin Excel, CSV ko JSON don ƙirƙirar tarin ta bugawa Ana shigo a cikin daidaitattun ra'ayi.

Mataki na 3: Ƙayyade filin

Kasancewa cikin Developer Mode , danna "abun ciki" tarin kuma zaɓi filin Labs shafin. Danna Ƙara Fields don ƙara da kuma daidaita sabbin fannoni waɗanda ke rarraba bayanai a cikin tarin.

Yadda za'a fara tare da restdb. i da Ƙirƙiri CMS mai saukiYadda za'a fara tare da restdb. io da Create a Simple CMSRelated Topics:
Kayayyakin & Tsare

Kowace takardun tattarawa zai ƙididdige bayanai game da shafi ɗaya a cikin shafin yanar gizon yanar gizo. Na kara da filayen biyar:

  • slug - filin rubutu don hanyar hanyar URL
  • take - filin rubutu don takardar shafi
  • jiki - filin rubutu na musamman don abun ciki na shafi
  • Hoton - filin hoto na musamman wanda ya ba da izini ga kowane adadin hotunan hotunan (waɗanda aka adana su a kan sauran).
  • aka wallafa - darajan farashi wanda dole ne ya zama gaskiya ga shafukan da za a iya bayyane.

Mataki na 4: Add Documents

Ana iya ƙara takardun zuwa wani tarin a kowane misali ko tsarin mai daɗi (ko ta hanyar API) . Ƙirƙiri ƙananan takardu tare da shafukan abubuwan shafuka:

Yadda za'a fara tare da restdb. i da Ƙirƙiri CMS mai saukiYadda za'a fara tare da restdb. io da Create a Simple CMSRelated Topics:
Kayayyakin & Tsare

Slug ya zama banza ga shafin gida.

Mataki na 5: Ƙirƙirar Yanar Gizo-Gizon Shafin Yanar Gizo (Zabin)

restdb. Ya samar da wani abu mai ban sha'awa wanda zai iya ƙirƙirar kuma ya dauki bakuncin yanar gizo ta hanyar amfani da bayanan bayanai a cikin tarin.

Shafukan yanar gizo ne wanda aka yi garkuwa a www- yourdbname . restdb. a'a amma zaka iya nuna wani yanki a shafukan. Don umarnin, danna Saituna daga jerin Database ko kuma a ƙasa na hannun hagu na bangaren sannan ka danna shafin yanar gizo .

Don ƙirƙirar shafin yanar gizon, Shafuka dole ne a saita su a cikin Yanayin Developer wanda ya bayyana samfura don duba abun ciki. Samfura sun ƙunshi snippet code wanda ya kafa:

  1. da mahallin - wani tambaya wanda ya samo asali mai kyau a cikin tarin, kuma
  2. HTML - tsarin da ke amfani da ƙaddamar samfurin samfurin don saka abun ciki cikin abubuwan da ya dace.

Danna Ƙara Page don ƙirƙirar shafi. Sunan shi sunan musamman /: slug - wannan yana nufin samfurin zai shafi kowane URL banda shafin gida (wanda ba shi da slug). Kashe Ajiye kuma komawa jerin lissafi, sannan danna /: slug shigarwa don shiryawa.

Canja zuwa Saituna shafin kuma tabbatar da rubutu / html an shigar da shi Abinda ke ciki da Buga an duba kafin bugawa Sabuntawa :

Yadda za'a fara tare da restdb. i da Ƙirƙiri CMS mai saukiYadda za'a fara tare da restdb. io da Create a Simple CMSRelated Topics:
Kayayyakin & Tsare

Yanzu juya zuwa Code don "/: slug" shafin. slug}} ","aka buga": gaskiya}}}{{/ mahallin}}

Wannan yana bayyana tambaya don haka samfurin zai iya samun dama ga takamaiman takardu daga ɗakunan mu . A wannan yanayin, muna ɗaukar takardun da aka wallafa wanda ya dace da slug wanda ya wuce URL ɗin.

Duk restdb. a cikin tambayoyi dawo da tsararren abubuwa. Idan ba a sake dawo da takardun daftarin aiki ba, zangon abubuwan da za a yi ba su da komai don haka za mu iya ƙara lambar don dawowa cewa shafin baya samuwa a nan gaba a cikin mahallin :

      <; doctype html> {{#unless docs. [0]}}     

Shafin ba <

ba

Yi haƙuri, wannan shafin ba za a iya gani ba. Da fatan a dawo daga baya.

{{/ sai dai idan}}

A ƙasa da wannan, za mu iya ƙila samfurin wanda ya raguwa da taken, jiki da kuma hotuna a cikin abubuwa masu dacewa HTML:

     {{#with docs. [0]}}         {{title}}  </ title>  <meta name = "viewport" content = "width = na'urar-nisa, sikelin farko = 1">  <style> jiki {font-iyali: sans-serif;font-size: 100%;launi: # 333;Ƙari-launi: #fff;max-nisa: 40em;Samun: 0 2m;gefe: 1em auto;} </ style>  </ head>  <jiki>  <BBC> {{#each image}} <img src = "https: // sitepoint-fbbf. restdb. / / / {{wannan}}" alt = "image" /> {{/ kowane}} <h1>  {{title}}  </ h1>  </ BBC>  <main> {{markdown jiki}} <p>   Ku koma cikin shafin gida   </p>  </ main>  </ body>  </ html> {{/ da}} </code>   </pre>  <p> 
Ka lura da ƙididdigar mu  <em>  jiki dole ne a fassara shi  </em>  tare da mai kula da mahimmanci.  </p>  <p> 
Ajiye lambar tare da Ctrl | Cmd + S ko ta koma zuwa  <strong>  Saituna  </strong>  shafin da bugawa  <strong>  Sabuntawa  </strong> .  </p>  <p> 
Lambar  <em>  /: slug  </em>  za ta shafi duk abin da muke  <em>  tarin  </em>  - sai dai don shafin gida, saboda wannan ba shi da wani slug! Don sanya shafin gida, ƙirƙirar  <strong>  Sabuwar Page  </strong>  tare da sunan  <em>  gida  </em>  tare da saitunan da abun ciki daidai. Kuna so ku yi samfuri don samfurin gida-shafi-musamman.  </p>  <p> 
Da zarar an sami ceto, za ka iya samun dama ga shafinka daga https: // www-  <em>  yourdbname  </em> . restdb. i /. Na kirkiro shafin yanar gizo mai sauƙi sau uku a https: // www-sitepoint-fbbf. restdb. i /.  </p>  <p> 
Don ƙarin bayani game da restdb. a shafin yanar gizo, koma zuwa: </p>  <ul>  <li> 
Shafukan yanar gizo da kuma Database Hosting Website Hosting
 </li>  <li> 
Sauran. a Dynamic Yanar Gizo Demo
 </li>  <li> 
Daidaitaccen samfurin samfuri
 </li>  </ul>  <h2> 
Mataki na 6: Tambayoyi API  <br>  </h2>  <p> 
Ƙirƙirar wani shafi don nuna bayananku na iya zama da amfani, amma za ku so a gina wani aikace-aikacen da aka buƙata da kuma sarrafa bayanai.  </p>  <p> 
restdb. ingancin REST API yana samar da bayanan sarrafawa ta hanyar HTTP: </p>  <ul>  <li>  HTTP GET buƙatun sake dawo da bayanai daga tarin
 </li>  <li>  Hidimar HTTP POST ta ƙirƙiri sabon takardun a cikin tarin
 </li>  <li>  Wurin buƙatar HTTP yana buƙatar abubuwan da aka sabunta a cikin tarin
 </li>  <li>  Tambayoyi HTTP PATCH ta ɗaukaka daya ko fiye da kaddarorin a cikin takardun a cikin tarin
 </li>  <li>  HTTP Sake buƙatun share takardun daga tarin
 </li>  </ul>  <p> 
Akwai adadin APIs don magance fayilolin watsa labaru da aka aika, bayanan bayanan yanar gizo da kuma wasika amma wanda za ku yi amfani da shi shine sau da yawa don samowa. Adireshin API shine: </p>  <p> 
https: //  <em>  yourdbname  </em> . restdb. I / sauran /  <em>  Tarin-sunan  </em>  / </p>  <p> 
Adireshin don tarin "abun ciki" na haka shine: </p>  <pre>   <code>  https: // sitepoint-fbbf. restdb. I / sauran / abun ciki / </code>   </pre>  <p> 
An aika tambayoyin zuwa wannan adireshin a matsayin mai lakabi da aka sanya sunan JSON mai lamba  <strong>  q  </strong> , e. g. samo duk rubutun da aka buga a cikin tarin: </p>  <pre>   <code>  https: // sitepoint-fbbf. restdb. Ana ba da mažallin API cikakken damar ta hanyar tsoho amma yana da kyau don ƙirƙirar mažallan da aka iyakance ga takamaiman ayyuka. Daga database  <strong>  Saituna  </strong> ,  <strong>  API  </strong>  shafin: </p>  <p>  <img src = "/ img / d8986f50c982f0ddf4bc964e05c738547. Png" alt = "Yadda za'a fara tare da restdb. i da Ƙirƙiri CMS mai saukiYadda za'a fara tare da restdb. io da Create a Simple CMSRelated Topics:
Kayayyakin & Tsare "/> <p> 
Danna  <strong>  Ƙara Sabo  </strong>  don ƙirƙirar sabon maɓalli. Abinda na halitta a nan an ƙayyade ga buƙatun GET (buƙatun) a kan ɗakunan  <em>  kawai  </em>  kawai. Ya kamata ka ƙirƙiri maɓallin ƙuntataccen ma'anar idan kana amfani da kundin lambar Ajax ta hanyar abokin ciniki tun lokacin da kirtani zai kasance a bayyane a cikin lambar.  </p>  <p> 
Yanzu yana yiwuwa a gina wani jagoran tambayoyin JavaScript  <em>  (An yi amfani da ES5 don tabbatar da daidaitattun giciye ba tare da wani mataki na farko ba!)  </em> : </p>  <pre>  <code class="javascript language-javascript"> // restdb. a cikin mai tambayavar restDB = (aiki  <span class="f-c-white l-mr3">  {// saita domin naka na DBvarapi = 'https: // sitepoint-fbbf. restdb. i / sauran / ',APIkey = '597dd2c7a63f5e835a5df8c4';// query da databaseaikin bincike (url, callback) {Sauran lokaci, xhr = sababbin XMLHttpRequest  <span class="f-c-white l-mr3"> ;// saita URL da kuma BBCxhr. bude ('GET', api + url);xhr. SakamakonRequestHeader ('x-apikey', APIkey);xhr. setRequestHeader ('nau'in abun ciki', 'aikace-aikacen / json');xhr. SetRequestHeader ('cache-control', 'no-cache');// mai kula da amsawaxhr. onreadystatechange = aiki  <span class="f-c-white l-mr3">  {idan (xhr. readyState! == 4) dawo;var err = (xhr da matsayin! == 200), data = null;clearTimeout (lokaci lokaci);idan (! err) {gwada {bayanai = JSON. parse (xhr amsa);}kama {e} {err = gaskiya;bayanai = xhr. amsa || Null;}}Komawa (kuskure, bayanai);};// timeouttimeout = saitaTimeout (aiki  <span class="f-c-white l-mr3">  {xhr. abort  <span class="f-c-white l-mr3"> ;kiraback (gaskiya, null);}, 10000);// fara kiraxhr. aika  <span class="f-c-white l-mr3"> ;}// hanyar bincike na jama'adawo {query: tambaya};})  <span class="f-c-white l-mr3"> ; </code>   </pre>  <p> 
Wannan lambar ta aika tambayoyin zuwa sauran. zuwa API ƙarshe kuma ya kafa harafin HTTP masu dacewa ciki har da  <strong>  x-apikey  </strong>  don maɓallin API. Yana da saurin idan amsa ya dauki tsawon lokaci goma. Ayyukan kiraback sun wuce kuskure da duk bayanan da aka dawo dashi azaman abu na asali. Misali: </p>  <pre>  <code class="javascript language-javascript"> // gudanar da tambayarestDB. tambaya ('/ content? q = {"da aka buga": gaskiya)',aiki (kuskure, bayanai) {// nasara!idan (! err) wasan bidiyo. shiga (bayanai);}); </code>   </pre>  <p> 
Kayan aiki zai samar da takardu daga takardun  <em>  abun ciki  </em>  tarin, e. g.  </p>  <pre>  <code class="javascript language-javascript"> [{_id: "1111111111111111",slug: "",title: "Shafin gida",jiki: "Shafin shafi na . ",image: [],buga: gaskiya},{_id: "22222222222222222",slug: "shafi-biyu",title: "Page biyu",jiki: "Shafin shafi na . ",image: [],buga: gaskiya},{_id: "33333333333333333",slug: "shafi-uku",title: "Wani shafi",jiki: "Shafin shafi na . ",image: [],buga: gaskiya}] </code>   </pre>  <p> 
Ana iya kiran API daga kowane harshe wanda zai iya yin buƙatar HTTP. restdb. i bada misalai na cURL, jQuery $. ajax, JavaScript XMLHttpRequest, NodeJS, Python, PHP, Java, C #, Objective-C da Swift.  </p>  <p> 
Na kirkiro misali mai kyau a Codepen. abin da ke ba ka damar bincika kirtani a take da kuma shafunan jiki kuma nuna sakamakon: </p> <p data-height="300" data-theme-id="6441" data-slug-hash="brWEqW" data-default-tab="js,result" data-user="SitePoint" data-embed-version="2" data-pen-title="restdb.io query" class="codepen"> Dubi Pen din. a query by SitePoint (@SitePoint) a kan CodePen.  </p>  <p>   </p>  <p> 
Yana wuce wannan tambaya: </p>  <pre>  <code class="javascript language-javascript"> {"$ ko": [{"take": {"$ regex": "searchstring"}},{"jiki": {"$ regex": "bincika"}}]} </code>   </pre>  <p> 
inda  <em>  bincika  </em>  shine binciken da aka shigar da mai amfani. Zaka iya shirya shafukan ta hanyar amfani da restdb. ingancin mai amfani na amma zai yiwu a gina CMS mai amfani da shi don sarrafa abubuwan. Yana buƙatar: </p>  <ol>  <li>  Wani sabon saiti. zuwa maballin API (ko musanya wanda yake da shi) don samun GET, POST, PUT, KATUWA DA KASA KASA KASA zuwa ga  <em>  abun ciki  </em> .  </li>  <li>  Mai amfani da ke dubawa don bincika ko bincika shafuka (wanda ke sama zai iya zama kyakkyawan farawa).  </li>  <li>  Hanyar fara sabon shafi ko GET abun ciki da ke ciki kuma sanya shi a cikin takarda mai shiryarwa.  </li>  <li>  Aikace-aikace don ƙarawa, sabunta ko share shafuka ta amfani da hanyoyin HTTP masu dacewa.  </li>  </ol>  <p> 
Tsarin gyarawa ya kamata ya gudana a kan na'urar ƙuntatawa ko a baya bayanan shiga don tabbatar kawai masu amfani da aka ƙware za su iya samun dama. Yi hankali kada a bayyana mahimmancin ku. zuwa maballin API idan ta amfani da lambar gefen abokin ciniki! </p>  <p> 
Ƙarin bayani: </p>  <ul>  <li> 
Hanyar bayanai tare da REST
 </li>  <li> 
Misalai na Code don REST API
 </li>  </ul>  <h2> 
Gwada restdb. a yau!  <br>  </h2>  <p> 
Wannan labarin yana amfani da ragowar. don gina CMS marar kyau, amma sabis ɗin ya dace da kowane aikin wanda ke buƙatar ajiya bayanai. Ana iya samun damar shigar da API na REST daga kowane harshe ko tsarin wanda ya sa ya dace da aikace-aikace tare da ƙananan ƙira, e. g. shafin yanar gizon yanar gizo da kuma wayoyin hannu.  </p>  <p> 
restdb. io zai samar da wani matsala mai amfani don sarrafawa na shigarwa software na kwamfutarka. Yana da sauki don amfani, azumi, iko, sosai scalable kuma da yawa da tsada fiye da sayen gwani basira! Kayan kuɗi na biyan kuɗi zai rage tun lokacin da dukkanin bayanai an adana su da kuma goyon baya a kan restdb. zuwa sabobin.  </p>  <p> 
A ƙarshe,  <em>  huta. Yau zai sa ku kara zama  </em> . Kuna iya mayar da hankalin akan babban aikace-aikacen saboda ajiyar bayanan bayanai ba zai damu da damuwa da ku ba.  </p>  <p> 
Fara gina gininku. a cikin bayanai a yau kuma bari mu san yadda za ka samu!  </p> <div class="Article_authorBio l-mv4 t-bg-white m-border l-pa3"><div class="l-d-f l-pt3"><img src = "/ img / d8986f50c982f0ddf4bc964e05c738548. com / avatar / 439aeaff7de2bae365adc3eb4947b44d? s = 96 & d = mm & r = g" alt = "Yadda za'a fara tare da restdb. i da Ƙirƙiri CMS mai saukiYadda za'a fara tare da restdb. io da Create a Simple CMSRelated Topics:
Kayayyakin & Tsare "/><div class="f-lh-title"><div class="f-c-grey-300"> Ku sadu da marubucin  </div> <div class="f-large">Craig Buckler<i class="fa fa-twitter"> </i> <i class="fa fa-google-plus"> </i> <i class="fa fa-facebook"> </i> <i class="fa fa-linkedin"> </i> <i class="fa fa-github"> </i>  </div>  </div>  </div> <div class="f-light f-lh-copy l-mt3"> Craig mai zaman kansa ne mai kula da yanar gizon yanar gizon yanar gizon wanda ya gina shafin farko na IE2. 0 a 1995. Tun daga wannan lokacin yana yin shawarwari da ka'idoji, amfani, da mafi kyau-aikin HTML5 dabaru. Ya rubuta fiye da 1,000 articles for SitePoint kuma za ka iya samun shi @craigbuckler </div>  </div>  </div>  </div>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </p>  </p>  </p>  </p>  </p>  </p>  </p>  </p>  </em>  </strong>  </pre>  </code>  </html>  </html>  </jiki>  </jiki>  </h1>  </h1>  </h1>  </kai>  </meta>  </meta>                                         
March 1, 2018