question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to store data?

See original GitHub issue

Hello,

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:closed
  • Created 8 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
koistyacommented, Mar 12, 2016

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.

1reaction
rdewolffcommented, Mar 10, 2016

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found