client-manager-fido 1.0.0 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +0 -0
  2. package/app.js +30 -0
  3. package/package.json +1 -1
package/README.md ADDED
Binary file
package/app.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const postgres = require("./src/modules/postgres");
2
2
  let psql = postgres();
3
+ const { Op } = require("sequelize");
3
4
 
4
5
  module.exports.add_client = async function(name, surname, birth_date, age){
5
6
  try{
@@ -42,12 +43,19 @@ module.exports.edit_client = async function(id, name, surname, birth_date, age){
42
43
  surname,
43
44
  birth_date,
44
45
  age,
46
+ modified_date: new Date()
45
47
  },{
46
48
  where:{
47
49
  id
48
50
  }
49
51
  })
50
52
 
53
+ client = await psql.clients.findOne({
54
+ where:{
55
+ id,
56
+ }
57
+ })
58
+
51
59
  return({
52
60
  msg: "edited",
53
61
  client
@@ -106,4 +114,26 @@ module.exports.get_element_by_id = async function(id){
106
114
  }catch(e){
107
115
  console.log(e + "")
108
116
  }
117
+ }
118
+
119
+ module.exports.get_element_by_id = async function(id, name, surname, from_date, to_date){
120
+ try{
121
+ psql = await psql;
122
+ let clients = await psql.clients.findAll({
123
+ where: {
124
+ id: id ? { [Op.eq]: id } : {},
125
+ name: name ? { [Op.iLike]: `%${name}%` } : {},
126
+ surname: surname ? { [Op.iLike]: `%${surname}%` } : {},
127
+ from_date: from_date ? { [Op.gte]: from_date } : {},
128
+ to_date: to_date ? { [Op.lte]: to_date } : {}
129
+ }
130
+ })
131
+
132
+
133
+ return ({
134
+ clients
135
+ })
136
+ }catch(e){
137
+ console.log(e + "")
138
+ }
109
139
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "client-manager-fido",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
5
  "main": "app.js",
6
6
  "scripts": {