Einkaufslisten anzeigen, Datenbankeinbindung

This commit is contained in:
Lukas Nowy
2018-10-27 01:10:46 +02:00
parent 5e3c83707f
commit 8e7d96310f
425 changed files with 77158 additions and 3 deletions

View File

@ -0,0 +1,19 @@
declare namespace PostgresInterval {
export interface IPostgresInterval {
years?: number;
months?: number;
days?: number;
hours?: number;
minutes?: number;
seconds?: number;
milliseconds?: number;
toPostgres(): string;
toISO(): string;
}
}
declare function PostgresInterval(raw: string): PostgresInterval.IPostgresInterval;
export = PostgresInterval;

126
express-server/node_modules/postgres-interval/index.js generated vendored Normal file
View File

@ -0,0 +1,126 @@
'use strict'
var extend = require('xtend/mutable')
module.exports = PostgresInterval
function PostgresInterval (raw) {
if (!(this instanceof PostgresInterval)) {
return new PostgresInterval(raw)
}
extend(this, parse(raw))
}
var properties = ['seconds', 'minutes', 'hours', 'days', 'months', 'years']
PostgresInterval.prototype.toPostgres = function () {
var filtered = properties.filter(this.hasOwnProperty, this)
// In addition to `properties`, we need to account for fractions of seconds.
if (this.milliseconds && filtered.indexOf('seconds') < 0) {
filtered.push('seconds')
}
if (filtered.length === 0) return '0'
return filtered
.map(function (property) {
var value = this[property] || 0
// Account for fractional part of seconds,
// remove trailing zeroes.
if (property === 'seconds' && this.milliseconds) {
value = (value + this.milliseconds / 1000).toFixed(6).replace(/\.?0+$/, '')
}
return value + ' ' + property
}, this)
.join(' ')
}
var propertiesISOEquivalent = {
years: 'Y',
months: 'M',
days: 'D',
hours: 'H',
minutes: 'M',
seconds: 'S'
}
var dateProperties = ['years', 'months', 'days']
var timeProperties = ['hours', 'minutes', 'seconds']
// according to ISO 8601
PostgresInterval.prototype.toISO = function () {
var datePart = dateProperties
.map(buildProperty, this)
.join('')
var timePart = timeProperties
.map(buildProperty, this)
.join('')
return 'P' + datePart + 'T' + timePart
function buildProperty (property) {
var value = this[property] || 0
// Account for fractional part of seconds,
// remove trailing zeroes.
if (property === 'seconds' && this.milliseconds) {
value = (value + this.milliseconds / 1000).toFixed(6).replace(/0+$/, '')
}
return value + propertiesISOEquivalent[property]
}
}
var NUMBER = '([+-]?\\d+)'
var YEAR = NUMBER + '\\s+years?'
var MONTH = NUMBER + '\\s+mons?'
var DAY = NUMBER + '\\s+days?'
var TIME = '([+-])?([\\d]*):(\\d\\d):(\\d\\d)\.?(\\d{1,6})?'
var INTERVAL = new RegExp([YEAR, MONTH, DAY, TIME].map(function (regexString) {
return '(' + regexString + ')?'
})
.join('\\s*'))
// Positions of values in regex match
var positions = {
years: 2,
months: 4,
days: 6,
hours: 9,
minutes: 10,
seconds: 11,
milliseconds: 12
}
// We can use negative time
var negatives = ['hours', 'minutes', 'seconds', 'milliseconds']
function parseMilliseconds (fraction) {
// add omitted zeroes
var microseconds = fraction + '000000'.slice(fraction.length)
return parseInt(microseconds, 10) / 1000
}
function parse (interval) {
if (!interval) return {}
var matches = INTERVAL.exec(interval)
var isNegative = matches[8] === '-'
return Object.keys(positions)
.reduce(function (parsed, property) {
var position = positions[property]
var value = matches[position]
// no empty string
if (!value) return parsed
// milliseconds are actually microseconds (up to 6 digits)
// with omitted trailing zeroes.
value = property === 'milliseconds'
? parseMilliseconds(value)
: parseInt(value, 10)
// no zeros
if (!value) return parsed
if (isNegative && ~negatives.indexOf(property)) {
value *= -1
}
parsed[property] = value
return parsed
}, {})
}

21
express-server/node_modules/postgres-interval/license generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Ben Drucker <bvdrucker@gmail.com> (bendrucker.me)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -0,0 +1,68 @@
{
"_from": "postgres-interval@^1.1.0",
"_id": "postgres-interval@1.1.2",
"_inBundle": false,
"_integrity": "sha512-fC3xNHeTskCxL1dC8KOtxXt7YeFmlbTYtn7ul8MkVERuTmf7pI4DrkAxcw3kh1fQ9uz4wQmd03a1mRiXUZChfQ==",
"_location": "/postgres-interval",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "postgres-interval@^1.1.0",
"name": "postgres-interval",
"escapedName": "postgres-interval",
"rawSpec": "^1.1.0",
"saveSpec": null,
"fetchSpec": "^1.1.0"
},
"_requiredBy": [
"/pg-types"
],
"_resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.1.2.tgz",
"_shasum": "bf71ff902635f21cb241a013fc421d81d1db15a9",
"_spec": "postgres-interval@^1.1.0",
"_where": "D:\\5CHITM\\Diplomarbeit\\smart-shopper\\SmartShopper\\express-server\\node_modules\\pg-types",
"author": {
"name": "Ben Drucker",
"email": "bvdrucker@gmail.com",
"url": "bendrucker.me"
},
"bugs": {
"url": "https://github.com/bendrucker/postgres-interval/issues"
},
"bundleDependencies": false,
"dependencies": {
"xtend": "^4.0.0"
},
"deprecated": false,
"description": "Parse Postgres interval columns",
"devDependencies": {
"standard": "^4.0.0",
"tape": "^4.0.0"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js",
"index.d.ts",
"readme.md"
],
"homepage": "https://github.com/bendrucker/postgres-interval#readme",
"keywords": [
"postgres",
"interval",
"parser"
],
"license": "MIT",
"main": "index.js",
"name": "postgres-interval",
"repository": {
"type": "git",
"url": "git+https://github.com/bendrucker/postgres-interval.git"
},
"scripts": {
"test": "standard && tape test.js"
},
"version": "1.1.2"
}

View File

@ -0,0 +1,46 @@
# postgres-interval [![Build Status](https://travis-ci.org/bendrucker/postgres-interval.svg?branch=master)](https://travis-ci.org/bendrucker/postgres-interval)
> Parse Postgres interval columns
## Install
```
$ npm install --save postgres-interval
```
## Usage
```js
var parse = require('postgres-interval')
var interval = parse('01:02:03')
//=> {hours: 1, minutes: 2, seconds: 3}
interval.toPostgres()
// 3 seconds 2 minutes 1 hours
interval.toISO()
// P0Y0M0DT1H2M3S
```
## API
#### `parse(pgInterval)` -> `interval`
##### pgInterval
*Required*
Type: `string`
A Postgres interval string.
#### `interval.toPostgres()` -> `string`
Returns an interval string. This allows the interval object to be passed into prepared statements.
#### `interval.toISO()` -> `string`
Returns an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Durations) compliant string.
## License
MIT © [Ben Drucker](http://bendrucker.me)