How to use it
To create a translatable schema, you can use localizableModel
:
server.js
;;; const mongodbUrl = 'mongodb://localhost:27017/my-db';const user = '';const pass = ''; mongoose;
mycollection.js:
; const Schema = mongooseSchema;const mycollection = translatableString: type: SchemaTypesObjectId ref: 'locale' someObject: translatableObjString: type: SchemaTypesObjectId ref: 'locale' ; const MyModel = locales;
router.js:
;;; const router = ; router; router
When requesting GET /mycollection/IDHERE?lang=en
it will return the collection populated:
When requesting GET /admin/mycollection?lang=en
, the language will be ignored (as defined in router example) and it will return all languages: