Skip to content

Releases: adonisjs/lucid

Improving model serialization process by allowing fields to pick or omit

01 May 10:03
Compare
Choose a tag to compare

The serialization process accepts a tree of fields to pick and omit for the model and its relationships. Example:

const user = await User.find(1)
user.serialize({
  fields: ['username', 'email', 'id'],
})

// Verbose mode
user.serialize({
  fields: {
    pick: ['username', 'email', 'id'],
    omit: ['id']
  },
})

When pick and omit both have the same set of properties, the omit will win.

Relationships

Quite often you would want to also cherry pick fields for relationships as well.

user.serialize({
  fields: {
    pick: ['username', 'email', 'id'],
    omit: ['id']
  },
  relations: {
    posts: {
      fields: ['title', 'body', 'published_at']
    }
  }
})

Feels verbose?

Well, you will never type these fields to pick or omit manually. Usually, you will be following an API standard like JSONAPI, which allows the consumer of your API to specify the fields. There we will be a preprocessor in between the model.serialize the user defined query string options. That preprocessor will convert the query string to this tree.

Commits

  • improvement: adding support to pick and omit fields during serialize process d3d4f92

v8.0.5...v8.1.0

Handful of bug fixes

30 Apr 15:40
Compare
Choose a tag to compare
  • improvement: allow whereNot contraints for the unique and the exists rules 1bdf5e6
  • feat: add useTransaction and useConnection methods 789f038
  • improvement: making ddl queries compute the query method and not the pretty printer 7d40daf
  • fix: update mysql config type to accept mysql2 as a client 2623e66
  • fix: use for of loop to iterate over registered connections bfdf53a

v8.0.4...v8.0.5

Improvements to migrations dry run output

28 Apr 04:17
Compare
Choose a tag to compare
  • fix: pretty sql queries with proper formatting 77f6043
  • chore: update dependencies d0c5c80

v8.0.3...v8.0.4

Improvements to logging and some new additions

27 Apr 10:22
Compare
Choose a tag to compare

Bug Fixes

  • Fix SimplePaginator.toJSON static type

Improvements

  • Do not register health checker, until one or more connections have health checks enabled
  • Improvements to the query debugging. Now debugging can be control globally, at connection level or at query level.

Additions

  • Added findBy and findByOrFail methods to model

Commits

  • improvement: serialize datetime to iso string 7091bab
  • feat: query.delete method, it is an alias for the existing .del method ea7166c
  • improvement: protect preload method to be called from a deleted instance eaff60a
  • feat: add findBy and findByOrFail methods 3d3a8f4
  • improvement: streamline query logging by disabling knex logger and user event emitter 21f01d6
  • improvement: register health checker only when one or more connections are using it 117ec61
  • chore: update dependencies 7611427
  • fix(types): fix type returned by SimplePaginator.toJSON (#535) e386e94

v8.0.2...v8.0.3

Removing redundant log statement

20 Apr 15:21
Compare
Choose a tag to compare
  • fix: remove redundant console.log statement 1c1dd25

v8.0.1...v8.0.2

Improvements to the sync method, along with some bug fixes

20 Apr 15:01
Compare
Choose a tag to compare
  • improvement: improve sync method to not select all pivot rows 76ebf32
  • fix: always set updatedAt when model is dirty d7e5672
  • fix: Database.transaction accept callback to be passed to the query client 5e07ed8
  • chore: update dependencies 072c794
  • fix(types): correct type of Model.createMany values parameter (#533) 6727f8e

v8.0.0...v8.0.1

Solidifying Lucid with bunch of new features and bug fixes

18 Apr 10:53
Compare
Choose a tag to compare

Highlights

  • Support for query scopes with proper intellisense
  • Option to define hooks by decorating functions
  • A standard way to listen for database query events using the Event module of AdonisJS.
  • Helper function to pretty print SQL query logs
  • Support for Pagination
  • Support for Global transactions. Helpful during tests
  • Added tests to run on MSSQL too.

Commits

  • feat: allow defining hooks via decorators ae2f398
  • style: fix after rebase c9b0e24
  • improvement: use toSQL method directly, since knex has added it to their types b3f9917
  • chore: cleanup dependencies f697a38
  • style: improve log message in migrations command 2a0db32
  • improvement: raise error when trying to merge or fill extra properties to model 003f1c4
  • improvement: raise error when trying to merge or fill extra properties to model 1167b54
  • refactor: use mustache syntax for stubs ebee5fb
  • chore: update dependencies b20776a
  • feat: accept custom data to set set on query event e9f944b
  • refactor: pass model name to query reporter for updates, deletes and inserts 87f9599
  • fix: return ModelQuery builder for update and deletes 4a6f165
  • refactor: re-organize code f09f4f6
  • fix: use fromSQL method to convert sql date times to luxon instances 40d528d
  • chore: update database config template to drop Contract from config types f058141
  • refactor: depreciate "debug" config property b536acc
  • refactor: cleaning up migration commands b6dc1ce
  • refactor: nest transaction queries inside profiler row 06f361a
  • feat: add querylogs pretty printer 4281d1f
  • feat: emit db queries 1466b31
  • test: fix breaking test 297acd1
  • fix: provider to export orm config 6bddf84
  • feat: expose SimplePaginator on database object for manual construction f533fe5
  • feat(paginator): add getUrlsForRange method 8cac552
  • feat: add first and firstOrFail as static model methods 05f2422
  • refactor: drop Contract keyword from everything except implmentable interfaces b5302d5
  • refactor: extract Model.defineScope to its own helper method 5c150b8
  • feat: implement fetch and find hooks 5e125f9
  • refactor: serialize dates to ISODate string by default be8a9f8
  • chore: update .env file d07d5ca
  • feat: implement relationships onQuery hook 9b58684
  • feat: implement query scopes 88cf86b
  • refactor: huge cleanup to simplify things all around f268dea
  • WIP 6c44456
  • refactor: cleanup query builder types 0096e76
  • test: add tests for clone method 6286276
  • feat: implement standard offset,limit based pagination d3584fe
  • feat(QueryBuilder): add clearLimit and clearOffset methods 6ba940f
  • test: add tests for union queries 6293d2f
  • refactor: add connection name to the query log messages a3a494b
  • feat: add schema.raw to get an instance of knex query builder 5570d10
  • test: use client.context over client._context after recent change in knex 2686a5c
  • fix: having method signature after knex upgrade 9ba7f89
  • chore: update dependencies f13f503
  • refactor: update code to work consistently with mssql 6874d59
  • fix: add missing dev dependency mssql d338c93
  • test: update tests to work cross database servers 8fa6cce
  • refactor: fixing import case 8cd21d6
  • chore: add support for running tests on mssql server 5c35853
  • feat: add getAllTables method to get a list of all table names as an array e48709f
  • feat: extend validator by adding unique and exists rules 4768c3c
  • feat: add support for self managed transactions 0e2f6ee
  • chore: update dependencies 3398653

v7.6.3...v8.0.0

Fixing make:model command

10 Mar 05:20
Compare
Choose a tag to compare
  • fix(make model): create command inside the application source 31bcbb4

v7.6.2...v7.6.3

Add make:model command

08 Mar 15:48
Compare
Choose a tag to compare
  • refactor: raise meaningful exceptions when undefined is passed ORM query methods 6864447
  • feat(cli): add make:model command (#525) 0f4a080

v7.6.1...v7.6.2

Add support for Global transactions

06 Mar 10:17
Compare
Choose a tag to compare
  • feat: add support for global transactions 5aebc31
  • chore: update dependencies 6780b44

v7.6.0...v7.6.1