loopback-objectid-mixin

Sets objectId type for model property

Usage no npm install needed!

<script type="module">
  import loopbackObjectidMixin from 'https://cdn.skypack.dev/loopback-objectid-mixin';
</script>

README

loopback-objectid-mixin

This module is designed for the Strongloop Loopback framework. It sets objectId type for model properties.

works only with loopback-connector-mongodb

install

  npm install --save loopback-objectid-mixin

mixinsources

Add the mixins property to your server/model-config.json like the following:

{
  "_meta": {
    "sources": [
      "loopback/common/models",
      "loopback/server/models",
      "../common/models",
      "./models"
    ],
    "mixins": [
      "loopback/common/mixins",
      "../node_modules/loopback-objectid-mixin",
      "../common/mixins"
    ]
  }
}

config

To use with your Models add the mixins attribute to the definition object of your model config.

  {
    "name": "Product",
    "properties": {},
    "mixins": {
      "ObjectidType": {
         "properties": ["userId"]
       }
    }
  }

options

option type description required
properties [String] properties which you want to set objectId type true