GroceriStar / groceristar-fetch

json arrays for Food Tech projects
https://groceristar.github.io/groceristar-fetch/
GNU General Public License v3.0
8 stars 18 forks source link

create methods, that will return big objects #60

Open atherdon opened 6 years ago

atherdon commented 6 years ago
atherdon commented 5 years ago

GL

structure of our collection should be:

[
{ 
  key: uuid(),  
  name: 'gl name',
  dep: [
    {
      id: uuid(),
       ing: [
        {
          id: uuid()
        }
      ]
    }
  ]
}
]

But be ready for example to create a different type of structure:

[
{ 
  key: uuid(),  
  name: 'gl name',
  ing: [
    {
      id: uuid(),
       dep: 
        {
          id: uuid()
        }     
    }
  ]
}
]
atherdon commented 5 years ago

first version was done by method getKeyArray

atherdon commented 5 years ago

third method will incorporate this structure


let Ingredients  = require(path.resolve(__dirname, 'ingredients'));
let Groceries    = require(path.resolve(__dirname, 'grocery'));
let Departments  = require(path.resolve(__dirname, 'departments'));
let Users        = require(path.resolve(__dirname, 'users'));

i also need another one object, related to users.
like we have a big number of Groceries
but all of them should be assigned with admin user.
Can you do it?
like one method that calling `getKeyArray` and creating users with ids, then extracting id only from groceries object and adding to one user array with ids of groceries
(this is actually our full database for groceristar right now)
atherdon commented 5 years ago

As additional methods, we can also create objects, related to this schemes(one of them is GS, for sure :))

atherdon commented 5 years ago

i have doubts about method getKeyArray first of all it's hard to understand what is he ding without printing it. second of all it's confusing what is related to key and what is related to value.

also i find out that this array return 790672 more items ] and i think it's a really big number. or maybe i'm wrong...

vadim9999 commented 5 years ago

@atherdon getKeyArray returns array of objects, that one object has property name - key from department, property value - key from ingredient. For example Department object has

{
name: FreshVegetables,
key:0000-0000
}

Ingredient

{
"name": "Asparagus",
 "department": "Fresh vegetables"
key: 1111-1111
}
{
"name": "Brocoli",
 "department": "Fresh vegetables"
key: 2222-2222
}

In result

{"0000-0000" : "1111-1111"},
{"0000-0000" : "2222-2222"},

Or we can remake it like

{"0000-0000" : ["1111-1111","2222-2222"]},

This method returns just relation between ingredients in one json and departments in another json. If database can import json with array that has object with array and this array will have another object for example

[{
 "1":[
       {"2":["3"]
             },
        {"2"}
      ]
}
]
atherdon commented 5 years ago

make sense

atherdon commented 5 years ago

ok, so for me - this is the only function that we can use in the middle, so we still need to have another method, that will call this method. btw, can you advice about 79k of array elements?

vadim9999 commented 5 years ago

@atherdon Sorry I have found my mistake. I will fix it

atherdon commented 5 years ago

not a problem. i'm still expanding this task - will share my results(task list) with you soon. this is why i un-assign you from this task. i thnk it should be better explaned

vadim9999 commented 5 years ago

We have a problem. If in Departments name of department is "Condiments / sauces" and in indgredients department is "Condiments / Sauces" it's defferrent string fields.

vadim9999 commented 5 years ago

We have 303 tied all ingredients with all departments

atherdon commented 5 years ago

We have a problem. If in Departments name of department is "Condiments / sauces" and in indgredients department is "Condiments / Sauces" it's defferrent string fields.

Can we catch such kind of things or only by eye? i'm aware of this problem. we need to find a way to do it #157

vadim9999 commented 5 years ago

if we need just to match strings I think we can uppercase all strings and then to compare it

atherdon commented 5 years ago

it's an interesting idea, but i think we should see this issue as part of the big issue. First of all - it's not only departments have duplicates. Second - Maria proposes to update the whole structure of departments. instead of having Dairy for all products, related to Milk, we'll have:

Dairy
  - Milk
    -- Cow Milk (ingredients/items/products)
    -- Soy Milk (ingredients/items/products)
  - Cheese
    -- Mozarella (ingredients/items/products)
    -- Parmesan (ingredients/items/products)
    -- Dor Blue (ingredients/items/products)
    -- Roquefort (ingredients/items/products)
atherdon commented 5 years ago

~we need to add methods, that have 'key' at https://github.com/GroceriStar/groceristar-fetch/pull/182~

vadim9999 commented 5 years ago

need I make another method like getKeyArrayDepAndIng for another table?

atherdon commented 5 years ago

Not at this moment. I'm still gaining all information together.

atherdon commented 5 years ago

if you wish to move this task forward - you can show me a method that will grab all grocery related information together. so I'll be one huge object. but the structure of this object is debatable, so only if you want to try - do it. or we can wait when I'll put all the important information for fetch into one place. Btw, did you saw content at 'discussion' task?

atherdon commented 5 years ago

if you want to try - tell me - and I'll create a separated task. because this thread is dirty and hard to follow