forked from loopbackio/loopback-next
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(repository): delete operation in hasOne relation and example hasOne
implemeted delete new feature on hasone relation. created an example of one to one application into examples folder "fix loopbackio#2233"
- Loading branch information
Raphael Dai
committed
Feb 6, 2019
1 parent
75731f9
commit 9093ae0
Showing
45 changed files
with
1,073 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
# Generated apidocs | ||
api-docs/ | ||
|
||
# Transpiled JavaScript files from Typescript | ||
/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist | ||
*.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"bracketSpacing": false, | ||
"singleQuote": true, | ||
"printWidth": 80, | ||
"trailingComma": "all" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"editor.rulers": [80], | ||
"editor.tabCompletion": "on", | ||
"editor.tabSize": 2, | ||
"editor.trimAutoWhitespace": true, | ||
"editor.formatOnSave": true, | ||
|
||
"files.exclude": { | ||
"**/.DS_Store": true, | ||
"**/.git": true, | ||
"**/.hg": true, | ||
"**/.svn": true, | ||
"**/CVS": true, | ||
"dist": true, | ||
}, | ||
"files.insertFinalNewline": true, | ||
"files.trimTrailingWhitespace": true, | ||
|
||
"tslint.ignoreDefinitionFiles": true, | ||
"typescript.tsdk": "./node_modules/typescript/lib" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Watch and Compile Project", | ||
"type": "shell", | ||
"command": "npm", | ||
"args": ["--silent", "run", "build:watch"], | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
}, | ||
"problemMatcher": "$tsc-watch" | ||
}, | ||
{ | ||
"label": "Build, Test and Lint", | ||
"type": "shell", | ||
"command": "npm", | ||
"args": ["--silent", "run", "test:dev"], | ||
"group": { | ||
"kind": "test", | ||
"isDefault": true | ||
}, | ||
"problemMatcher": ["$tsc", "$tslint5"] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Developer's Guide | ||
|
||
We use Visual Studio Code for developing LoopBack and recommend the same to our | ||
users. | ||
|
||
## VSCode setup | ||
|
||
Install the following extensions: | ||
|
||
- [tslint](https://marketplace.visualstudio.com/items?itemName=eg2.tslint) | ||
- [prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) | ||
|
||
## Development workflow | ||
|
||
### Visual Studio Code | ||
|
||
1. Start the build task (Cmd+Shift+B) to run TypeScript compiler in the | ||
background, watching and recompiling files as you change them. Compilation | ||
errors will be shown in the VSCode's "PROBLEMS" window. | ||
|
||
2. Execute "Run Rest Task" from the Command Palette (Cmd+Shift+P) to re-run the | ||
test suite and lint the code for both programming and style errors. Linting | ||
errors will be shown in VSCode's "PROBLEMS" window. Failed tests are printed | ||
to terminal output only. | ||
|
||
### Other editors/IDEs | ||
|
||
1. Open a new terminal window/tab and start the continous build process via | ||
`npm run build:watch`. It will run TypeScript compiler in watch mode, | ||
recompiling files as you change them. Any compilation errors will be printed | ||
to the terminal. | ||
|
||
2. In your main terminal window/tab, run `npm run test:dev` to re-run the test | ||
suite and lint the code for both programming and style errors. You should run | ||
this command manually whenever you have new changes to test. Test failures | ||
and linter errors will be printed to the terminal. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# one2one | ||
|
||
[![LoopBack](<https://github.com/strongloop/loopback-next/raw/master/docs/site/imgs/branding/Powered-by-LoopBack-Badge-(blue)[email protected]>)](http://loopback.io/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"ids": { | ||
"Supplier": 3, | ||
"Account": 6 | ||
}, | ||
"models": { | ||
"Supplier": { | ||
"one": "{\"id\":\"one\",\"name\":\"Raphael\"}", | ||
"two": "{\"id\":\"two\",\"name\":\"Drai\"}" | ||
}, | ||
"Account": { | ||
"no-relation": "{\"id\":\"no-relation\",\"accountManager\":\"Unknown Manager\"}", | ||
"ac-1": "{\"id\":\"ac-1\",\"accountManager\":\"RaphaelDraiManager\",\"supplierId\":\"one\"}", | ||
"ac-2": "{\"id\":\"ac-2\",\"accountManager\":\"Flora\",\"supplierId\":\"two\"}" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const application = require('./dist'); | ||
|
||
module.exports = application; | ||
|
||
if (require.main === module) { | ||
// Run the application | ||
const config = { | ||
rest: { | ||
port: +process.env.PORT || 3000, | ||
host: process.env.HOST || '10.240.105.240' || 'localhost', | ||
openApiSpec: { | ||
// useful when used with OASGraph to locate your application | ||
setServersFromRequest: true, | ||
}, | ||
}, | ||
}; | ||
application.main(config).catch(err => { | ||
console.error('Cannot start the application.', err); | ||
process.exit(1); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './src'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{ | ||
"name": "@loopback/example-one-2-one", | ||
"version": "1.3.1", | ||
"description": "Continuation of the hasOne example using relations in LoopBack 4.", | ||
"main": "index.js", | ||
"engines": { | ||
"node": ">=8.9" | ||
}, | ||
"scripts": { | ||
"build:apidocs": "lb-apidocs", | ||
"build": "lb-tsc es2017 --outDir dist", | ||
"build:watch": "lb-tsc es2017 --outDir dist --watch", | ||
"clean": "lb-clean *example-one-2-one*.tgz dist package api-docs", | ||
"lint": "npm run prettier:check && npm run tslint", | ||
"lint:fix": "npm run tslint:fix && npm run prettier:fix", | ||
"prettier:cli": "lb-prettier \"**/*.ts\"", | ||
"prettier:check": "npm run prettier:cli -- -l", | ||
"prettier:fix": "npm run prettier:cli -- --write", | ||
"tslint": "lb-tslint", | ||
"tslint:fix": "npm run tslint -- --fix", | ||
"pretest": "npm run build", | ||
"test": "lb-mocha \"dist/test/*/**/*.js\"", | ||
"test:dev": "lb-mocha --allow-console-logs dist/test/**/*.js && npm run posttest", | ||
"verify": "npm pack && tar xf loopback-todo-list*.tgz && tree package && npm run clean", | ||
"migrate": "node ./dist/src/migrate", | ||
"prestart": "npm run build", | ||
"start": "node ." | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/strongloop/loopback-next.git" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"@loopback/boot": "^1.0.8", | ||
"@loopback/context": "^1.4.0", | ||
"@loopback/core": "^1.1.3", | ||
"@loopback/openapi-v3": "^1.1.5", | ||
"@loopback/openapi-v3-types": "^1.0.3", | ||
"@loopback/repository": "^1.1.1", | ||
"@loopback/rest": "^1.5.1", | ||
"@loopback/rest-explorer": "^1.1.4", | ||
"@loopback/service-proxy": "^1.0.5", | ||
"loopback-connector-rest": "^3.1.1" | ||
}, | ||
"devDependencies": { | ||
"@loopback/build": "^1.1.0", | ||
"@loopback/http-caching-proxy": "^1.0.3", | ||
"@loopback/testlab": "^1.0.3", | ||
"@loopback/tslint-config": "^1.0.0", | ||
"@types/lodash": "^4.14.109", | ||
"@types/node": "^10.11.2", | ||
"lodash": "^4.17.10", | ||
"tslint": "^5.12.0", | ||
"typescript": "^3.2.2" | ||
}, | ||
"keywords": [ | ||
"loopback", | ||
"LoopBack", | ||
"example", | ||
"tutorial", | ||
"relations", | ||
"CRUD", | ||
"models", | ||
"account", | ||
"HasOne" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<title>hasOne relation example between supplier and account</title> | ||
|
||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="shortcut icon" type="image/x-icon" href="//v4.loopback.io/favicon.ico"> | ||
|
||
<style> | ||
h3 { | ||
margin-left: 25px; | ||
text-align: center; | ||
} | ||
|
||
a, a:visited { | ||
color: #3f5dff; | ||
} | ||
|
||
h3 a { | ||
margin-left: 10px; | ||
} | ||
|
||
a:hover, a:focus, a:active { | ||
color: #001956; | ||
} | ||
|
||
.power { | ||
position: absolute; | ||
bottom: 25px; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
} | ||
|
||
.info { | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%) | ||
} | ||
|
||
.info h1 { | ||
text-align: center; | ||
margin-bottom: 0; | ||
} | ||
|
||
.info p { | ||
text-align: center; | ||
margin-bottom: 3em; | ||
margin-top: 1em; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div class="info"> | ||
<h1>one2one</h1> | ||
<p>Version 1.0.0</p> | ||
|
||
<h3>OpenAPI spec: <a href="/openapi.json">/openapi.json</a></h3> | ||
<h3>API Explorer: <a href="/explorer">/explorer</a></h3> | ||
</div> | ||
|
||
<footer class="power"> | ||
<a href="https://v4.loopback.io" target="_blank"> | ||
<img src="https://loopback.io/images/branding/powered-by-loopback/blue/powered-by-loopback-sm.png" /> | ||
</a> | ||
</footer> | ||
</body> | ||
|
||
</html> |
Oops, something went wrong.