sails js - error when clean the collections in start up - sails.js

In my sails application I edit the config/models.js file as follows to clean the database when lifting the application.
migrate: 'drop',
connection: 'mongodb'
But when I try to run the application it displays the following error.
A hook (`orm`) failed to load!
error: Error (E_UNKNOWN) :: Encountered an unexpected error
MongoError: Index with name: _id_ already exists with different options
I am using sails version 0.10.5 ,any kind of help would be appreciated.

same here, when you have an error to the model the orm crashes, at least you have the error, sometimes with mysql you don't even have the error

the issue was, in some of my application's model files I have added following to attributes list.
attributes: {
_id: {
type: 'string',
unique: true
}
}
since I have added unique true to the attribute, it causes an error when I try to clean the collections on start up. more information about this issue can be found on Index already exists with different options error while using createIndex() in latest MongoDB java driver

Related

Unable to connect to OrientDB - "Error in database URL: the engine was not specified"

Trying to connect to a new OrientDB (v3.2.15) database in Docker:
connect env remote:localhost root root;
create database apples plocal;
But am getting:
Error: com.orientechnologies.orient.core.exception.OConfigurationException: Error in database URL: the engine was not specified. Syntax is: <engine>:<db-type>:<db-name>[?<db-param>=<db-value>[&]]*. URL was: apples
Looking at the source code I can see : is required, or it'll through an exception - but the documentation says the opposite and my commands look correct.
Any ideas what I'm doing wrong, please?

Strange error when initializing Postgres database in FeathersJS

I am converting a FeathersJS system from MySQL to Postgres and facing some problems.
After changing the connection string
"mysql": "mysql://user:password#server:port/database"
to
"postgres": "postgres://user:password#server:port/database"
at config/default.json, I changed the dialect from mysql to pg at feathers/sequelize.js.
But when I started with npm run dev I got the following JSON error message, never seen before.
{
"_bitField":18087936,
"_fulfillmentHandler0":{
"name":"SequelizeConnectionError",
"parent":{
"name":"error",
"length":93,
"severity":"FATAL",
"code":"3D000",
"file":"postinit.c",
"line":"855",
"routine":"InitPostgres"
},
"original":{
"name":"error",
"length":93,
"severity":"FATAL",
"code":"3D000",
"file":"postinit.c",
"line":"855",
"routine":"InitPostgres"
}
},
"name":"SequelizeConnectionError",
"parent":{
"name":"error",
"length":93,
"severity":"FATAL",
"code":"3D000",
"file":"postinit.c",
"line":"855",
"routine":"InitPostgres"
},
"original":{
"name":"error",
"length":93,
"severity":"FATAL",
"code":"3D000",
"file":"postinit.c",
"line":"855",
"routine":"InitPostgres"
}
}
After researching a bit with no success, here I am to ask if someone has ever seen this message.
I already tried the dialect as pg and postgres at feathers/sequelize.js, just to check if it would make any difference, but it didn't.
A true beginner error! My fault!
When I created the Postgres (Docker) container, I forgot to create the database itself!
I created the role and gave it the needed permissions, but forgot to create the database corresponding to my connection string.
The Postgres error code mentioned in my question (3D000) corresponds to invalid_catalog_name, i.e., no database corresponding to the connection string.
One may easily check this at Postgres documentation, but I was mistakenly looking for this error code at FeathersJS documentation.

ODatabaseException OrientDB Record Error

I'm struggling to fix my orientdb database. I'm getting the error:
Error: com.orientechnologies.orient.core.exception.ODatabaseException: Error on retrieving record #58:65894 (cluster: cluster_name_here)
I'm running REPAIR DATABASE --fix-graph and that's when i get this error. Is there any other suggestions in approaching this? This is also the case when running CHECK DATABASE
I tried using this link as a resource: https://orientdb.com/docs/last/Console-Command-Repair-Database.html

Applying oplog but found duplicate key error

Mongo version is 3.0.6, I have a process to apply oplog from another database to destination database by mongodump and mongorestore by using --oplogReplay option.
But I found duplicate key error messages many time, source and target database have the same structure (indies and fields) that is impossible to have duplicated record on target because it should be error on source db first.
And error message looks like this
2017-08-20T00:55:55.900+0000 Failed: restore error: error applying oplog: applyOps: exception: E11000 duplicate key error collection: <collection_name> index: <field> dup key: { : null }
And today I found a mystery message like this
2017-08-25T01:02:14.134+0000 Failed: restore error: error applying oplog: applyOps: not master
What's a mean? And my understanding, mongorestore has "--stopOnError" option that means the default process, if have any errors, the restore process will skip and move on. But I got above error and then the restore process has been terminated anytime. :(
This does not answer directly to your question, sorry for that, but...
If you need to apply oplog changes for database A to database B, it would be better to use mongo-connector program, than mongodump/mongorestore -pair.

MongoDB E11000 duplicate key error on mydb.testlookup.$name dup key:{:dummy123} in meanstack using angular-fullstack generator

Hi I am trying to create a simple project using angular-fullstack generator I have running my MongoDB and nodejs in windows, everything installed and running perfectly. I have created one schema as follows
'use strict';
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
var TestlookupSchema = new Schema({
name: String,
ccode: String,
description: String,
info: String,
active: Boolean
});
module.exports = mongoose.model('Testlookup', TestlookupSchema);
I didn't touch any other default schemas that comes along with generator demo app.
whenever I am inserting any record into this collection I am getting below error
E11000 duplicate key error index: mydb.testlookup.$name dup key: {:dummy123}
I am using windows 7 as operating system
NodeJS 4.xx
Mongodb 3.x
What might be causing this error?
I got same problem but I resolved it by deleting index. Actually when generate angular-fullstack app it will create Thing schema there will be name field and when you create another schema which has same name field, so it will create Index. If you enter same data like in your case "dummy123" in name field for both schemas it will give duplicate key entry index error - E11000
Solution for this if you are in windows
Gotto Mongo Shell
command prompt - mongo.exe
use mydb
db.mydb.getIndexes()
You will find name as index just drop and recreate it
db.mydb.dropIndex( "name")
Now you restart your node app using grunt serve you wont get that problem again