LoopBack

nodejs, Loopback change model name / table name (with mysql)

一世执手 提交于 2019-12-13 02:13:17
问题 use Loopback(nodejs) with mysql. I want to change the model name/table name. (different name) I don't want to see table name (in API URL) table name = 'super_member' model name = 'member' api url = '/api/member/'; what can I do? 回答1: You can customize models by adding a mysql property on the model and/or on the properties : { "name": "yourModelName", "base": "PersistedModel", "idInjection": false, "mysql": { "schema": "YOUR DATABASE NAME", "table": "YOUR MYSQL TABLE NAME" }, "properties": {

Nodejs Loopback 4 add bearer token config into swagger explorer

。_饼干妹妹 提交于 2019-12-12 13:00:33
问题 I'm using Nodejs loopback 4 to build API project and using JWT token for authentication component. But when I explore built-in swagger of loopback (localhost:3000/explorer as default) then navigate to one of my API url, there is no input place for JWT Bearer Token. How can I config that let swagger display a JWT token input (that's just like it's display param query, request body input...) Thanks in advance 回答1: Hello from the LoopBack team 👋 Authentication in general, and token-based

Centos 7搭建LVS+Keepalived高可用Web服务群集

不想你离开。 提交于 2019-12-12 09:19:42
一、LVS+Keepalived高可用群集 Keepalived的设计目标是构建高可用的LVS负载均衡群集,可以调用ipvsadm工具来创建虚拟服务器、管理服务器池,而不仅仅用作双机热备。使用Keepalived构建LVS群集更加简便易用,主要优势体现在:对LVS负载调度器实现热备切换,提高可用性;对服务器池中的节点进行健康检查,自动移除失效节点,恢复后再重新加入。 在基于LVS+Keepalived实现的LVS群集结构中,至少包括两台热备的负载调度器,三台以上的节点服务器。此博客将以DR模式的LVS群集为基础,增加一台从负载调度器,使用Keepalived来实现主、从调度器的热备,从而构建兼有负载均衡、高可用两种能力的LVS网站群集平台。 因为该服务涉及到了LVS技术,相关LVS概述及配置博文可以参考以下链接: Centos 7之LVS负载均衡群集概述 构建基于地址转换(LVS—NAT)模式的负载均衡群集 构建基于直接路由模式(DR)的负载均衡群集 1、案例环境如下: 使用Keepalived构建LVS群集时,也需要用到ipvsadm管理工具,但大部分工作会由Keepalived自动完成,不需要手动执行ipvsadm(除了查看和监控群集以外)。 2、环境分析 1)、2个调度器和2个web节点使用同一个网段地址,可以直接和外网通信。为了共享存储的安全性

How to remove a property from document - mongo / loopback

这一生的挚爱 提交于 2019-12-12 01:46:14
问题 I have an old property on one of my models, and I'd like to remove it from all the documents in a collection. I've tried posting via /upsertWithWhere using the id to update by: passing in undefined for the value which results in "http error 400 bad request" passing in null which just sets the property to null I also was thinking I could do a regular POST and just overwrite each document, but these particular documents are large and I'd rather not do that. Is there a way to simply patch it?

Loopback get data from one module to anothee

蓝咒 提交于 2019-12-11 17:18:52
问题 I am using loopback3 for file storage attachment.js and i have the persistedmodel career.js for storing the data. Now i want to fetch the file name in the career.js. how to do this. career.js 'use strict'; const app = require('../../server/server'); module.exports = function(Career) { Career.afterRemote('create', function(context, remoteMethodOutput, next) { next(); // console.log(context.result) Career.app.models.Email.send({ to: 'john@gmail.com', from: 'noreply@gmail.com', subject: 'Career

loopback where field is null

▼魔方 西西 提交于 2019-12-11 15:56:39
问题 How can I query a field which is null? I get a a sql error filter=[where][category_id][eq][null] results in SELECT WHERE category_id'null' ORDER BY id using latest version of loopback and loopback-connector-mysql 回答1: You can use filter like /model?filter[where][category_id][eq]=null As you see in loopback /medias?filter[where][keywords][inq]=foo&filter[where][keywords][inq]=bar reference link : here 来源: https://stackoverflow.com/questions/52485321/loopback-where-field-is-null

How do I use the access token in Loopback?

不羁的心 提交于 2019-12-11 12:04:22
问题 I am trying to use Loopback as a mobile backend. I am also following this example: http://docs.strongloop.com/display/public/LB/Introducing+the+Coffee+Shop+Reviews+app After I login on my iOS device, I receive an access token. All good. Now I want to call an endpoint that requires authentication. Just calling the endpoint gets me the message "AUTHENTICATION REQUIRED". So I try to attach the access token to the request parameters as {"access_token":"1241341234513..."}. However, nothing happens

Getting joined data from strongloop/loopback

江枫思渺然 提交于 2019-12-11 11:31:38
问题 How can I get data from two joined tables? Suppose, there are two models called Category (CategoryId, CategoryName) and Product(ProductId, ProductName, CategoryId), Is there a way to get a result like:(ProductId, ProductName, CategoryId, CategoryName) 回答1: There should be a relation between your Category model and your Product model. A Category hasMany Products and each Product belongsTo a Category. So your model json files should be something like Category: { "name":"Category", "properties":

How to insert multiple records in loopback

試著忘記壹切 提交于 2019-12-11 08:31:11
问题 I have collection of records for a model. But there is no method available to insert into Mongo db in Fireloop. Is there any method available ? 回答1: Yes there is, in you models create endpoint give an array instead of object Example: in Products model this.productApi.create( [ {name: "Toy Car"}, {name: "Purse"}, {name: "Charger"} ] ).subscribe((res)=>console.log(res)) Hope this helps. 回答2: Yes, PersistedModel.create([data], callback) As Arguments Optional data argument. Can be either a single

Docker-compose with Loopback and Mongodb fail to connect mongdb

萝らか妹 提交于 2019-12-11 07:16:15
问题 I have been learning docker lately and I was unable to make a connection between my loopback api and mongodb. The application works fine in local dev environment. With docker-compose my mongodb server runs at localhost:27017 and my react-frontend serves at localhost:3000 and looks fine. Only loopback is unable to connect to mongodb and throws the following errors: loopback_1 | Web server listening at: http://localhost:8080 loopback_1 | Browse your REST API at http://localhost:8080/explorer