Closed
Description
old schema(without title filed):
const notesSchema = {
version: 0,
title: 'naotes schema',
description: 'descript a note',
type: 'object',
properties: {
id : {
type: 'string',
primary: true
},
content: {
type: 'string'
}
},
required: ['content']
}
new schema:
const notesSchema = {
version: 1,
title: 'naotes schema',
description: 'descript a note',
type: 'object',
properties: {
id : {
type: 'string',
primary: true
},
content: {
type: 'string'
},
title: {
type: 'string'
}
},
required: ['content']
}
create collection:
db.collection({
name: 'notes',
schema: notesSchema,
migrationStrategies: {
1: (oldDoc) => {
console.log('migrate from 0 to 1...' + oldDoc.id)
oldDoc.title = 'test title'
return oldDoc
}
}
})
run app and log will be print all the time.
Metadata
Assignees
Labels
No labels