Git Product home page Git Product logo

Comments (2)

willviles avatar willviles commented on September 1, 2024

Also, to get lux seed to work in the test app, I had to make a slight amendment to /test/test-app/db/seed.js. It appears connection is undefined, so connection.batchInsert() throws the following error:

TypeError: Cannot read property 'batchInsert' of undefined
    at Object.keys.map.reduce (/Users/will/Code/lux/test/test-app/dist/bundle.js:1402:33)
    at Array.reduce (native)
    at seed (/Users/will/Code/lux/test/test-app/dist/bundle.js:1401:9)
    at /Users/will/Code/lux/test/test-app/node_modules/knex/lib/transaction.js:81:20
    at runCallback (timers.js:651:20)
    at tryOnImmediate (timers.js:624:5)
    at processImmediate [as _immediateCallback] (timers.js:596:5)
From previous event:
    at /Users/will/Code/lux/test/test-app/node_modules/knex/lib/transaction.js:75:10
    at runCallback (timers.js:651:20)
    at tryOnImmediate (timers.js:624:5)
From previous event:
    at new Transaction (/Users/will/Code/lux/test/test-app/node_modules/knex/lib/transaction.js:68:41)
    at Client_SQLite3.transaction (/Users/will/Code/lux/test/test-app/node_modules/knex/lib/client.js:158:12)
    at Function.transaction (/Users/will/Code/lux/test/test-app/node_modules/knex/lib/util/make-knex.js:75:21)
    at Database.then.store (/Users/will/.nvm/versions/node/v6.10.0/lib/node_modules/lux-framework/src/packages/cli/commands/dbseed.js:23:22)

The following code ran the seeds successfully:

import __fixtures__ from './__fixtures__.json'

const CHUNK_SIZE = 100

export default async function seed(trx) {
  const promises = Object
    .keys(__fixtures__)
    .map(key => [
      key,
      __fixtures__[key].map(row => (
        Object.assign(row, {
          created_at: new Date(row.created_at),
          updated_at: new Date(row.updated_at),
        })
      ))
    ])
    .reduce((arr, [table, rows]) => {
      arr[arr.length] = trx
        .batchInsert(table, rows, CHUNK_SIZE)
        .transacting(trx)
      return arr
    }, [])

  return Promise.all(promises)
}

from lux.

zacharygolba avatar zacharygolba commented on September 1, 2024

@willviles I was able to reproduce your issue regarding updating has many through relationships. I'm going to look into this a bit deeper and see if there is an easy fix.

In the mean time, could you expose the through model's controller and modify the relationships from there? I confirmed that it is working in the in v1.2.1.

Add Relationship

POST /friendships HTTP/1.1
Content-Type: application/vnd.api+json
Content-Length: 282

{
  "data": {
    "type": "friendships",
    "relationships": {
      "follower": {
        "data": {
          "id": ":id",
          "type": "users"
        }
      },
      "followee": {
        "data": {
          "id": ":id",
          "type": "users"
        }
      }
    }
  }
}

Remove Relationship

DELETE /friendships/:id HTTP/1.1

from lux.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.