How to store data?
See original GitHub issueHello,
I’m trying to learn React tool and I would like to develop a simple website.
I will wish to create a very simple CRUD: create, read, update and delete an article (text only). I managed to do so with Express and Mongoose but I don’t know how with react starter kit.
I installed mongoose:
npm install --save mongoose
And I added in server.js
mongoose.connect('mongodb://localhost/react-starter-kit');
var db = mongoose.connection;
db.on('error', function () {
throw new Error('unable to connect to database');
});
I created a “models” folder and I created “articleModel.js”
var mongoose = require('mongoose');
var schema = new mongoose.Schema({
title : String,
content : String
});
module.exports = articleModel = mongoose.model('articleModel', schema);
How to add a new article then display all articles in the database?
I recently discovered React, thank you for your help.
<bountysource-plugin>
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
5 Ways to Back up Your Data and Keep It Safe - Lifewire
Keep It in the Cloud · Save to an External Hard Drive · Burn It to CD, DVD, or Blu-ray · Put It...
Read more >What is data storage? - IBM
File storage, also called file-level or file-based storage, is a hierarchical storage methodology used to organize and store data. In other words, data...
Read more >What is Data Storage? Data Storage Types & Attributes - CDW
Data storage essentially means that files and documents are recorded digitally and saved in a storage system for future use. Storage systems may ......
Read more >Storing data sets | AP CSP (article) | Khan Academy
Most applications store data in a database, a system that stores data on a computer in a way that can be easily accessed,...
Read more >Top Ways to Store Your Digital Files - Amber by LatticeWork
Desktop Storage. Despite many external solutions for digital files, some people still store their photos, videos, and content files on their ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Currently only the authentication logic contains db access code -
src/core/passport
. PostgreSQL seems to be very popular choice of databases, especially since it does also have document storage similar to MongoDB. All user accoutns have exactly the same schema - email, password hash, registration date, the list of roles. That kind of data might be better stored in SQL tables I believe, where transactions are properly handled and data integrity is inforced out of the box.In additional to Postgres, I would really like to add Azure SQL Database, MongoDB, and SQLite versions of
src/core/passport
, so that RSK users may pick the appropritate implementation for their solution stack.Why not use Mongo in GraphQL?
Here is the nice tutorial from Kadira on GraphQL - they have a section “Using real data source” at https://learngraphql.com/basics/using-a-real-data-source. It’s really showing a nice example on how to hook up MongoDB in GraphQL, using promised-mongo (https://www.npmjs.com/package/promised-mongo).
Maybe this help!