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的更多相关文章

  1. node.js & create file

    node.js & create file node js create file if not exists https://nodejs.org/api/fs.html#fs_fs_ope ...

  2. Node.js面试题:侧重后端应用与对Node核心的理解

    Node是搞后端的,不应该被被归为前端,更不应该用前端的观点去理解,去面试node开发人员.所以这份面试题大全,更侧重后端应用与对Node核心的理解. node开发技能图解 node 事件循环机制 起 ...

  3. 使用node中的express解决vue-cli加载不到dev-server.js的问题

    在使用vue开发过程中,难免需要去本地数据地址进行请求,而原版配置在dev-server.js中,新版vue-webpack-template已经删除dev-server.js,改用webpack.d ...

  4. 《唐三学node.js系列》—魂士篇&&三哥初始node.js

    前言 如果你有一定的前端基础,比如 HTML.CSS.JavaScript.jQuery.那么Node.js 能让你以最低的成本快速过渡成为一个全栈工程师(我称这个全栈为伪全栈,我认为的全栈也要精通数 ...

  5. no data type for node

    java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.IdentNode  \-[IDE ...

  6. 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 ...

  7. The Model represents your data structures.

    w模型代表数据结构. https://www.codeigniter.com/userguide3/overview/mvc.html http://codeigniter.org.cn/user_g ...

  8. 報錯: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 ...

  9. 【集成学习】sklearn中xgboot模块中fit函数参数详解(fit model for train data)

    参数解释,后续补上. # -*- coding: utf-8 -*- """ ############################################## ...

随机推荐

  1. 最值(min、max)与极值的理解

    max(a,b)=−min(−a,−b) 如果 a≥b ⇒ max(a,b)=a,−a≤−b,⇒ 同理 min(a,b)=−max(−a,−b) 1. 最值 最小:不能更少,如果是整数关系的话,也即从 ...

  2. Linux 常用解压缩归档命令

    linux 常见压缩.归档工具 创建压缩工具 压缩工具 后缀 描述 compress/uncompress .Z 早期工具,现在不常见了 gzip/gunzip .gz 进几年比较火的工具 bzip2 ...

  3. Monkey服务器命令

  4. scrapy爬取知乎某个问题下的所有图片

    前言: 1.仅仅是想下载图片,别人上传的图片也是没有版权的,下载来可以自己欣赏做手机背景但不商用 2.由于爬虫周期的问题,这个代码写于2019.02.13 1.关于知乎爬虫 网上能访问到的理论上都能爬 ...

  5. BZOJ3277: 串(后缀自动机,Parent树,Dfs序)

    Description 字符串是oi界常考的问题.现在给定你n个字符串,询问每个字符串有多少子串(不包括空串)是所有n个字符串中 至少k个字符串的子串(注意包括本身). Input 第一行两个整数n, ...

  6. python运算符优先级表

    运算符 描述 lambda Lambda表达式 or 布尔“或” and 布尔“与” not x 布尔“非” in,not in 成员测试 is,is not 同一性测试 <,<=,> ...

  7. 【Codeforces Round #453 (Div. 2) A】 Visiting a Friend

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 维护最右端的端点就好. [代码] #include <bits/stdc++.h> using namespace st ...

  8. 导出查询结果到csv文件

    set colsep ,   set feedback off   set heading off   set trimout on   spool my.csv  select * from emp ...

  9. 16.用Spring Boot颠覆Java应用开发

    转自:https://www.cnblogs.com/aishangJava/p/5971288.html Java开发概述: 使用Java做Web应用开发已经有近20年的历史了,从最初的Servle ...

  10. 关于javascript中私有作用域的预解释

    1.如何区分私有变量还是全局变量 1).在全局作用域下声明(预解释的时候)的变量是全局变量 2).在“私有作用域中声明的变量”和“函数的形参”都是私有变量 在私有作用域中,我们代码执行的时候遇到一个变 ...