[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 -*- """ ############################################## ...
随机推荐
- 新手前端笔记之--初识html标签
接触前端(好大气的名字啊)已经一个多月了,看了很多视频和博客,有了一定的感性认识,但还是需要总结一下以便系统化所学习的知识,就从html标签开始吧.关于标签,谈论最多的就是简洁和语义化.简洁指html ...
- STL中erase()的陷阱
最近在刷stl源码剖析这本书时,对于vector的erase()函数引起了我的注意 在删除单个元素时是这样定义的: iterator erase(iterator position){ !=end() ...
- 洛谷 P1598 垂直柱状图
P1598 垂直柱状图 题目描述 写一个程序从输入文件中去读取四行大写字母(全都是大写的,每行不超过72个字符),然后用柱状图输出每个字符在输入文件中出现的次数.严格地按照输出样例来安排你的输出格式. ...
- 81.内存模式实现cgi查询
创建全局的二级指针 char ** g_pp;//全局的二级指针 获取数据有多少行 //获取行数 int getimax() { ; FILE *pf = fopen(path, "r&qu ...
- css实现水波纹效果
1. HTML 代码: <div class="example"> <div class="dot"></div> < ...
- python基础--数值类型和序列类型
Python中数值类型:int(整数),float(浮点数),True/False(布尔值,首字母必须大写) int:1 #任意整数 float:2.3 #小数 python赋值: a = ...
- POJ 3041 Asteroids 最小覆盖数
http://poj.org/problem?id=3041 题目大意: 一辆宇宙飞船在一个小行星带中,你知道,这很危险.他有一种武器,可以清除掉一行或一列的小行星.问把小行星全部清除最少的武器使用次 ...
- iOS开发 非常全的三方库、插件、大牛博客等等
UI 下拉刷新 EGOTableViewPullRefresh- 最早的下拉刷新控件. SVPullToRefresh- 下拉刷新控件. MJRefresh- 仅需一行代码就可以为UITableVie ...
- 【Codeforces Round #445 (Div. 2) D】Restoration of string
[链接] 我是链接,点我呀:) [题意] 给你n个字符串. 让你构造一个字符串s. 使得这n个字符串. 每个字符串都是s的子串. 且都是出现次数最多的子串. 要求s的长度最短,且s的字典序最小. [题 ...
- 【】queue
[链接]点击打开链接 [题意] 实话实说,给 OIER 大神们排队这种工作是最让人头疼的事情了.因为同学们都有自尊 心,都不愿意排后面. 现在共有 n 个同学要排成一列,每个同学有两个属性:影响力和承 ...