[Node.js] Create a model to persist data in a Node.js LoopBack API
In this lesson you will learn what a LoopBack model is, you will create a Product model using the LoopbBack CLI. The product model will be based off the built-in PersistedModel which gives it basic functionality like Create, Ready, Update, Delete and some more. Using the API Explorer you can interact with the new model, store, retrieve, edit and delete the product data.
Create a REST API model:
lb model
Give the information needed, it can generate all the rest api.
There are few files will be created.
common/models/[model_name].js
common/models/[model_name].json
There is one file will be modified:
server/model-config.json:
"Product": {
"dataSource": "db",
"public": true
}
So if you want to remove the model, you can delete those generated stuff.
If the data are stored in memory, it means once you restart the server, the data will lost, one way to keep the data for development:
datasources.json:
{
"db": {
"name": "db",
"connector": "memory",
"file": "db.json"
}
}
Add "file" prop, it will store data inside the db.json.
[Node.js] Create a model to persist data in a Node.js LoopBack API的更多相关文章
- node.js & create file
node.js & create file node js create file if not exists https://nodejs.org/api/fs.html#fs_fs_ope ...
- Node.js面试题:侧重后端应用与对Node核心的理解
Node是搞后端的,不应该被被归为前端,更不应该用前端的观点去理解,去面试node开发人员.所以这份面试题大全,更侧重后端应用与对Node核心的理解. node开发技能图解 node 事件循环机制 起 ...
- 使用node中的express解决vue-cli加载不到dev-server.js的问题
在使用vue开发过程中,难免需要去本地数据地址进行请求,而原版配置在dev-server.js中,新版vue-webpack-template已经删除dev-server.js,改用webpack.d ...
- 《唐三学node.js系列》—魂士篇&&三哥初始node.js
前言 如果你有一定的前端基础,比如 HTML.CSS.JavaScript.jQuery.那么Node.js 能让你以最低的成本快速过渡成为一个全栈工程师(我称这个全栈为伪全栈,我认为的全栈也要精通数 ...
- no data type for node
java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.IdentNode \-[IDE ...
- java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.MethodNode(尼玛,蛋疼的错误)
java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.MethodNode \-[M ...
- The Model represents your data structures.
w模型代表数据结构. https://www.codeigniter.com/userguide3/overview/mvc.html http://codeigniter.org.cn/user_g ...
- 報錯:One or more validation errors were detected during model generation:System.Data.Edm.EdmEntityType: : EntityType 'Movie' has no key
報錯:One or more validation errors were detected during model generation:System.Data.Edm.EdmEntityType ...
- 【集成学习】sklearn中xgboot模块中fit函数参数详解(fit model for train data)
参数解释,后续补上. # -*- coding: utf-8 -*- """ ############################################## ...
随机推荐
- php学习笔记5
PHP 常量 常量值被定义后,在脚本的其他任何地方都不能被改变. 一个常量由英文字母.下划线.和数字组成,但数字不能作为首字母出现. (常量名不需要加 $ 修饰符). 注意: 常量在整个脚本中都可以使 ...
- Object.prototype.toString.call(value)
使用Object.prototype上的原生toString()方法判断数据类型,使用方法如下: Object.prototype.toString.call(value) 1.判断基本类型: Obj ...
- [置顶]
MVC三层架构在各框架中的特征
1.从结构上分析jsp+servlet图解原理: 在基于mvc设计模式下的最原始的jsp+Servlet框架,在某种程度上是不能够达到mvc最直观的体现.当客户端发送请求到服务器时,服务器会将从客户端 ...
- [TS] Implement a doubly linked list in TypeScript
In a doubly linked list each node in the list stores the contents of the node and a pointer or refer ...
- chrome 的input 上传响应慢问题解决方案
<input type="file" accept="image/png,image/jpeg,image/gif" class="form-c ...
- 洛谷 P2069 松鼠吃果子
P2069 松鼠吃果子 题目描述 有N个一种松鼠喜欢吃的果子由下向上串排成一列,并标号1,2,...N.一只松鼠从最下果子开始向上跳,并且第i次跳可以一次跳过i*i*i除以5的余数+1个果子(=i*i ...
- Android通过startService播放背景音乐简单演示样例
关于startService的基本使用概述及其生命周期可參见博客<Android中startService的使用及Service生命周期>. 本文通过播放背景音乐的简单演示样例,演示sta ...
- postman和fiddler的基本使用
本文转自:https://www.cnblogs.com/qq909283/p/6826578.html 写在前面:本文主要的章节规划: 1.什么是接口测试 另外,有的时候会直接调用别的公司的接口,比 ...
- 2.Docker初体验【Docker每天5分钟】
原文:2.Docker初体验[Docker每天5分钟] Docker给PaaS世界带来的“降维打击”,其实是提供了一种非常便利的打包机制.该机制打包了应用运行所需要的整个操作系统,从而保证了本地环境和 ...
- [WASM] Call a JavaScript Function from WebAssembly
Using WASM Fiddle, we show how to write a simple number logger function that calls a consoleLog func ...