Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    darkghoul79
    @darkghoul79
    any help/alternative solution would be nice.
    darkghoul79
    @darkghoul79

    I was able to tweak it in order generate the right query,

    owner() {
        // return this.belongsTo('User', 'buyerId', 'id') .through("Items"), 'id', 'orderId')
        const relation = this.belongsTo('User', 'buyerId', 'id') .through("Items"), 'id', 'orderId')
    
        relation.relatedData.throughIdAttribute = 'orderId'
        return relation
      }

    But unfortunately, its not returning owner info/record.

    Georgy Shabunin
    @twist900
    hi, is it possible to use bookshelf with oracle db?
    simonecogno
    @simonecogno

    I have some issue with fetching related models of a model.
    The model definition is this:

    app.database.Model.extend({
            tableName: 'variation_score',
    
            variations: function() {
                this.belongsToMany(app.models.Variation)
            }
    }

    And I would like to fetch the variation later in my code like this:

    new app.models.VariationScore({id: variationScore.id})
                    .fetch({withRelated:{variations: function (qb) { qb.column('name') }}})
                    .then(viariationScoreWithVariations=> {
                             console.log(viariationScoreWithVariations);
                   });

    But the related models are not fetched correctly. Any ideas how to do it?

    I also tried:

    .fetch({withRelated: 'variations'})
    .fetch({withRelated: ['variations']})

    But also don't work.

    Oli Lalonde
    @olalonde
    Hola
    What's the recommended way to store data on models that shouldn't be persisted?
    directly as a property?
    tomoat
    @tomoat
    How use where …in in bookshelf ?
    Georgy Shabunin
    @twist900
    @tomoat should be where('column_name', 'in', ['stuff1', 'yo'])
    or .query((qb) => qb.whereIn('column_name', ['stuff1', 'stuff2']))
    Georgy Shabunin
    @twist900
    Does anyone know how to deal with the following problem. I eager load related models using withRelated in fetch, and it works perfectly - thanks bookshelf/knex team. My question is how can I eager load only certain relations, instead of all. Example case: I need to fetch an Author with only his latest published Book. Using .fetch(withRelated: [{ books: (qb) => qb.max('publish_date') }] ) will run .max on all of the Books tables, but I need max value between those related to that Author.
    or for example how can I limit the amount of eager loaded relations?
    Jason Shin
    @JasonShin
    Guys, when you are using jsonb field, is it possible to set some required properties of the json object through bookshelf?

    for example, when you are inserting a new row on a table with a jsonb field,
    I'd like to make it mandatory for each jsonb to have

    {
      a: string,
      b: int,
    }

    structure

    or would you just normalize it to multiple tables? (i really like jsonb though)
    Salvador López Mendoza
    @sallomendo
    Hi guys
    Salvador López Mendoza
    @sallomendo
    Position.forge({
      coordinates: st.point(-99.133208, 19.432608)
    }).save().then((result) => {
      console.log(result.get('coordinates'))
    })
    It returns
    Raw {
      client:
       Client_PG {
         config:
          { client: 'pg',
            connection: [Object],
            migrations: [Object],
            seeds: [Object] },
         connectionSettings: { database: 'wizelingo_api_development' },
         driver:
          PG {
            domain: null,
            _events: {},
            _eventsCount: 0,
            _maxListeners: undefined,
            defaults: [Object],
            Client: [Object],
            Query: [Object],
            Pool: [Object],
            _pools: [],
            Connection: [Object],
            types: [Object],
            native: [Getter] },
         __cid: 'client0',
         pool:
          Pool {
            _factory: [Object],
            _inUseObjects: [Array],
            _draining: false,
            _waitingClients: [Object],
            _availableObjects: [Array],
            _asyncTestObjects: [],
            _count: 3,
            _removeIdleTimer: [Object],
            _removeIdleScheduled: true },
         valueForUndefined:
          Raw {
            client: [Circular],
            sql: 'DEFAULT',
            bindings: undefined,
            _wrappedBefore: undefined,
            _wrappedAfter: undefined,
            _debug: undefined },
         _events:
          { start: [Function],
            query: [Function],
            'query-error': [Function],
            'query-response': [Function] },
         _eventsCount: 4,
         makeKnex: [Function: makeKnex],
         version: '9.6.2' },
      sql: 'ST_Point(?, ?)',
      bindings: [ -99.133208, 19.432608 ],
      _wrappedBefore: undefined,
      _wrappedAfter: undefined,
      _debug: undefined }
    Shouldn't the model be populated with the result of the insertion?
    Cory Simmons
    @corysimmons
    Is it possible to do a hasOne through with Bookshelf?
    RYeah Sh
    @pantchox
    Hi, i really like bookshelf, but i think the documentation is very poor
    you would say i should do PR prob but i am still learning, and the examples are not intuitive and so clear what each method purpose is, i needed to google "bookshelf tutorial" examples etc to find.
    anyway i am not complaining i am just saying that its a shame because it looks very well structured but not so many real world examples
    Leonardo Silveira
    @sombriks
    Hi everyone, please take a look at my new article comparing bookshelf with other ORM's: https://sombriks.com.br/#/blog/0011-about-jpa-sequelize-and-bookshelf.md
    yellow
    @yellowBirdy
    Hey Hey, Anybody here?
    Adil Osama Rasheed
    @w3villa-adil
    Hello All
    yellow
    @yellowBirdy
    awfully quite here
    Ali Dalal
    @Ali-Dalal

    Hi all,
    question, can I pluck many to many relation when I eager load using withRelated?

    example: let's say I have a many-to-many relation between books and students
    what I need to do I want to return a list of students including an array of ids only

    [{
    name: 'student_name1',
    books: [1,2,3,4,5]
    },{
    name: 'student_name2',
    books: [5,6,7]
    }]
    Create MERN App
    @mernjs

    Hello Everyone,

    MERN Micro Framework provides starter kits for building web, desktop and mobile apps in pure JavaScript.

    https://www.npmjs.com/package/create-mernjs-app

    If you have any query or suggestions. Please let me know.