Ivan Asmer 4 роки тому
батько
коміт
3c3d84cbd8
1 змінених файлів з 4 додано та 5 видалено
  1. 4 5
      src/front-models.mjs

+ 4 - 5
src/front-models.mjs

@@ -145,7 +145,6 @@ export default async function createModels2(gql, config={create: 'Upsert', updat
                         LIST(){
                             this[name] = []
                             const otherType = inTypes(ofType.name)
-                            console.log(data, name)
                             if (otherType && data && data[name])
                                 this[name] = data[name].map(otherEntity => otherEntity && (new classes[otherType.name](otherEntity, otherEntity._id && Object.keys(otherEntity).length === 1)))
                             else if (data && typeof data === 'object' && name in data) this[name] = data[name] || []
@@ -248,22 +247,22 @@ export default async function createModels2(gql, config={create: 'Upsert', updat
                     }
                 }
 
-                static async find(query={}, cursorCalls={}){
+                static async find(query={}, cursorCalls={}, deepness=1){
                     const gqlQuery = `
                         query ${name}Find($query: String){
                             ${name}Find(query: $query)
-                                ${projectionBuilder(type)}
+                                ${projectionBuilder(type, deepness +1)}
                         }
                     `
                     let result = await gql.request(gqlQuery, {query: JSON.stringify([query, cursorCalls])})
                     return result[name + 'Find'].map(entity => new classes[name](entity))
                 }
 
-                static async findOne(query){
+                static async findOne(query, deepness=1){
                     const gqlQuery = `
                         query ${name}FindOne($query: String){
                             ${name}FindOne(query: $query)
-                                ${projectionBuilder(type)}
+                                ${projectionBuilder(type, deepness +1)}
                         }
                     `
                     let result = await gql.request(gqlQuery, {query: JSON.stringify([query])})