Comments (6)
For overwrite error the following example helped me alot.
// OverwriteModelError: Cannot overwrite User
model once compiled.
https://github.com/LanmeijingLucky/micro-Mongoose-example
const initColl = () => {
if(mongoose.models.Log) {
return mongoose.model('Log')
}
else {
return mongoose.model('Log', LogSchema);
}
}
module.exports = initColl();
from micro-dev.
I use something like
const mongoose = require('mongoose');
var schema = new mongoose.Schema({
_id: mongoose.Schema.Types.ObjectId,
title: Array,
slug: String,
fields: Array,
definitions: Array,
meta: {
createdAt: Date,
updatedAt: Date,
publishAt: Date,
unpublishAt: Date
}
});
const getModel = () => {
if (mongoose.models.Page) {
return mongoose.model('Page')
} else {
return mongoose.model('Page', schema, 'Pages');
}
}
module.exports = getModel()
const Page = require('./dbSchema.js');
Page.find((err, data) => {...
from micro-dev.
You may want to ignore your schema files so it will not reload them.
Assuming you put schema files in <project_dir>/src/models
please run micro dev with -i **/src/models
. This will neither watch those files nor rerun them
from micro-dev.
Thanks for the quick response! :)
I'm afraid that doesn't seem to work, I've tried a few variants, and I have models in the src folder
micro-dev --ignore src/models/*.js index.js
micro-dev --ignore src/models/ index.js
micro-dev -i ./src/models index.js
I think the -i switch isn't registered as it falls over saying that "File changed: src/models/user.js", which it did.
from micro-dev.
since -i receive a pattern matching absolute paths, so you have to start with **
.
Btw, if you really want to change the content of src/models/user.js
, I don't think micro-dev hot reload model would work.
from micro-dev.
brilliant! 👍
from micro-dev.
Related Issues (20)
- Restore compatibility with micro@canary
- Update chokidar to v3 HOT 1
- Add cli arguments to documentation
- apollo-server-micro floods console with introspection logs HOT 3
- Provide an option to disable the auto copy to clipboard behaviour
- --ignore option not accepting glob HOT 1
- micro with next js restart every time on next compile
- micro-dev restarts on non-source code changes
- Yargs Parser Security Vulnerability
- Update all dependencies HOT 1
- Add ESLint and move to TypeScript
- print name of module file being used on startup.
- Purpose of SIGUSR2 signal? HOT 1
- Not compatible with `micro` v10.x HOT 3
- Windows node debugger: SyntaxError: missing ) after argument list HOT 1
- micro-dev exits on error HOT 3
- error Command failed with exit code 140 HOT 1
- UnhandledPromiseRejectionWarning thrown when content-type is not sent HOT 1
- add to readme: how to use custom now.json files with now-env
- Disable console logging? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micro-dev.