Postgresql error with Knex Adapter in KeystoneJS 5: 'Error: Cannot read property 'find' of undefined' - postgresql

I am new to Postgresql (more familiar with Mongo) but our DevOps want me to transition a KeystoneJS project from Mongo to Postgresql. I followed the KeystoneJS instructions and all went fine until I tried adding the 'atCreated' plugin, specifically the 'createdAtField' plugin, to get a created date in my list. I started getting DB errors, and, thinking that I needed to rebuild the database, I ran the KeystoneJS init script to drop the database and rebuild it. Since then, I've gotten the following error:
$ tsc && cross-env NODE_ENV=development DISABLE_LOGGING=true keystone --entry=tsout/index.js dev --port=4545
ℹ Command: keystone dev --entry=tsout/index.js --port=4545
✔ Validated project entry file ./tsout/index.js
✔ Keystone server listening on port 4545
✔ Initialised Keystone instance
⠋ Connecting to databaseType "OEmbed" is missing a "__resolveType" resolver. Pass false into "resolverValidationOptions.requireResolversForResolveType" to disable this warning.
setting up cron job
⠙ Connecting to database knex:query select 1+1 as result undefined +0ms
⠹ Connecting to database knex:query SHOW server_version; undefined +65ms
✖ Connecting to database
Error: Cannot read property 'find' of undefined
at /Users/ranthony/Documents/projects/yaa-keystone/node_modules/#keystonejs/utils/dist/utils.cjs.dev.js:57:21
at async executeDefaultServer (/Users/ranthony/Documents/projects/yaa-keystone/node_modules/#keystonejs/keystone/bin/utils.js:114:3) {
errors: {
KnexAdapter: TypeError: Cannot read property 'find' of undefined
at /Users/ranthony/Documents/projects/yaa-keystone/node_modules/#keystonejs/adapter-knex/lib/adapter-knex.js:258:31
at Array.forEach (<anonymous>)
at KnexListAdapter._postConnect (/Users/ranthony/Documents/projects/yaa-keystone/node_modules/#keystonejs/adapter-knex/lib/adapter-knex.js:257:24)
at /Users/ranthony/Documents/projects/yaa-keystone/node_modules/#keystonejs/adapter-knex/lib/adapter-knex.js:73:19
at Array.forEach (<anonymous>)
at KnexAdapter.postConnect (/Users/ranthony/Documents/projects/yaa-keystone/node_modules/#keystonejs/adapter-knex/lib/adapter-knex.js:72:38)
at KnexAdapter.connect (/Users/ranthony/Documents/projects/yaa-keystone/node_modules/#keystonejs/adapter-knex/node_modules/#keystonejs/keystone/lib/adapters/index.js:29:38)
at async pReflect (/Users/ranthony/Documents/projects/yaa-keystone/node_modules/p-reflect/index.js:5:17)
at async Promise.all (index 0)
at async executeDefaultServer (/Users/ranthony/Documents/projects/yaa-keystone/node_modules/#keystonejs/keystone/bin/utils.js:114:3)
}
}
The DB is obviously empty, but KeystoneJS allows you to set up a new database based on the current lists using
const keystone = new Keystone({
name: PROJECT_NAME,
adapter: new KnexAdapter({ dropDatabase: true })
});
I went back to a prior branch, hoping to undo the errors (except the dropped DB of course), but the error persists.
For what it's worth, these are the KeystoneJS versions I'm using:
"#keystonejs/adapter-knex": "^7.0.0",
"#keystonejs/adapter-mongoose": "^5.2.0",
"#keystonejs/app-admin-ui": "^5.8.0",
"#keystonejs/app-graphql": "^5.1.0",
"#keystonejs/app-next": "^5.1.0",
"#keystonejs/app-static": "^5.1.0",
"#keystonejs/auth-password": "^5.1.0",
"#keystonejs/field-content": "^5.4.0",
"#keystonejs/fields": "^6.3.0",
"#keystonejs/fields-markdown": "^5.1.0",
"#keystonejs/fields-wysiwyg-tinymce": "^5.2.0",
"#keystonejs/file-adapters": "^5.5.0",
"#keystonejs/keystone": "^5.5.0",
"#keystonejs/list-plugins": "^5.1.2",
"#keystonejs/oembed-adapters": "^5.1.0",

Your knex adapter also needs the connection string:
const { KnexAdapter: Adapter } = require('#keystonejs/adapter-knex');
const adapterConfig = { knexOptions:{
connection: 'postgres://<your-user>:<your-paswrd>#<your-host>:<your-port>/<your-db>'
},
dropDatabase:true
};
and then call the adapter when creating your keystone project
const keystone = new Keystone({
name: PROJECT_NAME,
adapter: new Adapter(adapterConfig),
});

Related

Cannot read property 'prototype' of undefined - nestjs with typeorm and mongoDB

I'm setting up a simple API using nestjs with typeorm and mongodb. However when I make a simple http request I get the following error
[Nest] 8852 - 09/28/2021, 6:06:03 PM [ExceptionsHandler] Cannot read property 'prototype' of undefined +4874934ms TypeError: Cannot read property 'prototype' of undefined at FindCursor.cursor.toArray (C:\Users\admin\Documents\projects\shoplist\api\node_modules\typeorm\entity-manager\MongoEntityManager.js:669:37) at MongoEntityManager.<anonymous> (C:\Users\admin\Documents\projects\shoplist\api\node_modules\typeorm\entity-manager\MongoEntityManager.js:60:54) at step (C:\Users\admin\Documents\projects\shoplist\api\node_modules\tslib\tslib.js:143:27) at Object.next (C:\Users\admin\Documents\projects\shoplist\api\node_modules\tslib\tslib.js:124:57) at fulfilled (C:\Users\admin\Documents\projects\shoplist\api\node_modules\tslib\tslib.js:114:62) at processTicksAndRejections (internal/process/task_queues.js:95:5)
offices.controller.ts
#Get('/list')
findAll() {
return this.officesService.findAll();
}
offices.service.ts
async findAll() {
try {
const offices = await this.officesRepository.find();
return { success: true, message: 'Office successfully retrieved!', data: offices }
} catch(e) {
throw new InternalServerErrorException({ success: false, error: e.message })
}
}
I honestly don't know why it gives me error 500 with that message. Any idea what's happening?
These errors seam like a mongodb version problem. If you are using mongodb > 3, Typeorm doesn't support yet. They have PR open at github --> https://github.com/typeorm/typeorm/issues/7907
It's issue of mongodb version with typeorm.
typeorm doesn't have support for >3 version yet.
Run this to resolve issue.
mongodb#3 #types/mongodb#3
Complete dependencies
npm install typeorm #nestjs/typeorm mongodb#3 #types/mongodb#3
Resolved same issue following this.

I want to insert with mikro-orm, but it dont find my table :c (TableNotFoundException)

So
Console:
yarn dev
yarn run v1.22.10
$ nodemon dist/index.js
[nodemon] 2.0.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node dist/index.js`
[discovery] ORM entity discovery started, using ReflectMetadataProvider
[discovery] - processing entity Post
[discovery] - entity discovery finished, found 1 entities, took 21 ms
[info] MikroORM successfully connected to database postgres on postgresql://postgres:*****#127.0.0.1:5432
[query] begin
[query] insert into "post" ("created_at", "title", "updated_at") values ('2021-04-05T21:04:23.126Z', 'my first post', '2021-04-05T21:04:23.126Z') returning "_id" [took 12 ms]
[query] rollback
TableNotFoundException: insert into "post" ("created_at", "title", "updated_at") values ('2021-04-05T21:04:23.126Z', 'my first post', '2021-04-05T21:04:23.126Z') returning "_id" - relation "post" does not exist
at PostgreSqlExceptionConverter.convertException (P:\.Projektek\lireddit-server\node_modules\#mikro-orm\postgresql\PostgreSqlExceptionConverter.js:36:24)
at PostgreSqlDriver.convertException (P:\.Projektek\lireddit-server\node_modules\#mikro-orm\core\drivers\DatabaseDriver.js:194:54)
at P:\.Projektek\lireddit-server\node_modules\#mikro-orm\core\drivers\DatabaseDriver.js:198:24
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async PostgreSqlDriver.nativeInsert (P:\.Projektek\lireddit-server\node_modules\#mikro-orm\knex\AbstractSqlDriver.js:150:21)
at async ChangeSetPersister.persistNewEntity (P:\.Projektek\lireddit-server\node_modules\#mikro-orm\core\unit-of-work\ChangeSetPersister.js:55:21)
at async ChangeSetPersister.executeInserts (P:\.Projektek\lireddit-server\node_modules\#mikro-orm\core\unit-of-work\ChangeSetPersister.js:24:13)
at async UnitOfWork.commitCreateChangeSets (P:\.Projektek\lireddit-server\node_modules\#mikro-orm\core\unit-of-work\UnitOfWork.js:496:9)
at async UnitOfWork.persistToDatabase (P:\.Projektek\lireddit-server\node_modules\#mikro-orm\core\unit-of-work\UnitOfWork.js:458:13)
at async PostgreSqlConnection.transactional (P:\.Projektek\lireddit-server\node_modules\#mikro-orm\knex\AbstractSqlConnection.js:53:25)
at async UnitOfWork.commit (P:\.Projektek\lireddit-server\node_modules\#mikro-orm\core\unit-of-work\UnitOfWork.js:183:17)
at async SqlEntityManager.flush (P:\.Projektek\lireddit-server\node_modules\#mikro-orm\core\EntityManager.js:486:9)
at async SqlEntityManager.persistAndFlush (P:\.Projektek\lireddit-server\node_modules\#mikro-orm\core\EntityManager.js:438:9)
previous error: insert into "post" ("created_at", "title", "updated_at") values ('2021-04-05T21:04:23.126Z', 'my
first post', '2021-04-05T21:04:23.126Z') returning "_id" - relation "post" does not exist
at Parser.parseErrorMessage (P:\.Projektek\lireddit-server\node_modules\pg-protocol\dist\parser.js:278:15)
at Parser.handlePacket (P:\.Projektek\lireddit-server\node_modules\pg-protocol\dist\parser.js:126:29)
at Parser.parse (P:\.Projektek\lireddit-server\node_modules\pg-protocol\dist\parser.js:39:38)
at Socket.<anonymous> (P:\.Projektek\lireddit-server\node_modules\pg-protocol\dist\index.js:10:42)
at Socket.emit (events.js:315:20)
at Socket.EventEmitter.emit (domain.js:467:12)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
at Socket.Readable.push (internal/streams/readable.js:223:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
length: 166,
severity: 'ERROR',
code: '42P01',
detail: undefined,
hint: undefined,
position: '13',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'd:\\pginstaller_13.auto\\postgres.windows-x64\\src\\backend\\parser\\parse_relation.c',
line: '1376',
routine: 'parserOpenTable'
}
Index.ts:
import { MikroORM } from "#mikro-orm/core";
import { __prod__ } from "./constants";
import { Post } from "./entities/Post";
import mikroConfig from "./mikro-orm.config";
const main = async () => {
const orm = await MikroORM.init(mikroConfig);
await orm.getMigrator().up;
const post = orm.em.create(Post, { title: "my first post" });
await orm.em.persistAndFlush(post);
};
main().catch((err) => {
console.error(err);
});
Post.ts:
import { Entity, PrimaryKey, Property } from "#mikro-orm/core";
#Entity()
export class Post {
#PrimaryKey()
_id!: number;
#Property({ type: "date" })
createdAt = new Date();
#Property({ type: "date", onUpdate: () => new Date() })
updatedAt = new Date();
#Property({ type: "text" })
title!: string;
}
mikro-orm.config.ts:
import { __prod__ } from "./constants";
import { Post } from "./entities/Post";
import { MikroORM } from "#mikro-orm/core";
import path from "path";
export default {
migrations: {
path: path.join(__dirname, "./migrations"),
pattern: /^[\w-]+\d+\.[tj]s$/,
},
entities: [Post],
dbName: "postgres",
debug: !__prod__,
type: "postgresql",
password: "hellothere",
} as Parameters<typeof MikroORM.init>[0];
And the migration I created with npx mikro-orm migration:create:
import { Migration } from '#mikro-orm/migrations';
export class Migration20210405205411 extends Migration {
async up(): Promise<void> {
this.addSql('create table "post" ("_id" serial primary key, "created_at" timestamptz(0) not null, "updated_at" timestamptz(0) not null, "title" text not null);');
}
}
After that im compiling it to js btw, but I guess the problem will be somewhere at my code or idk plz help me, I can give you more info just plz help, I've been trying to fix this bug for 5 hours :/
Btw Im doin Ben Awad's 14 hour fullstack tutorial if its matter.
The TableNotFoundException happens when you try to add data before initializing the table's schema (or structure).
Passing the --initial as in Mosh's Answer did not work for me, possibly because I am passing a username and password in ./mikro-orm.config.ts.
I used Mikro-ORM's SchemaGenerator to initialize the table as seen here in the official docs.
Add the following lines before adding data to post in your main function in index.ts:
const generator = orm.getSchemaGenerator();
await generator.updateSchema();
The main function in index.ts should now look like this:
const main = async () => {
const orm = await MikroORM.init(mikroConfig);
await orm.getMigrator().up;
const generator = orm.getSchemaGenerator();
await generator.updateSchema();
const post = orm.em.create(Post, { title: "my first post" });
await orm.em.persistAndFlush(post);
};
updateSchema creates a table or updates it based on .entities/Post.ts. This could cause issues when the Post file is updated, I haven't run in to any while following Ben's tutorial. Although, I'd still recommend creating ./create-schema.ts and running it when needed as shown in the official docs.
I have had the same issue. This is what I did:
I deleted the migrations folder as well as the dist folder
I ran npx mikro-orm migration:create --initial
After that, I restarted yarn watch and yarn dev and it worked for me.
Notice the --initial flag. I would recommend to check the official documentation. The migrations table is used to keep track of already executed migrations. When you only run npx mikro-orm migration:create, the table will not be created and therefore MikroORM is unable to check if the migration for the Post entity has already been performed (which includes creating the respective table on the database).
Ben does not use the --initial flag in his tutorial, he might have already ran it prior to the tutorial.
I had a similar problem myself (Also doing Ben Awad's tutorial).
I used Mikro-ORM's schema generator to initialize the table like in Fares47's Answer, but the problem still persisted.
It wasn't until I set my user to have Superuser permissions that it started working.
I am using postgresql for my data base which I downloaded using homebrew. If you have a similar set up here is what I did:
Start up psql in your terminal using psql postgres. If you want, you can view your users and check their permissions by typing \du in the shell. Then, to change the permissions for a user use the command ALTER ROLE <username> WITH SUPERUSER;. Make sure you include a semi-colon or else it will not run the command.
Check this article out for more info on psql commands.
I have the same problem i solved by install the ts-node on project
npm i -D ts-node
and set useTsNode on package.json as true.
The problem is the mikro-orm cli only add ts files paths in configPaths if the property useTsNode is true and ts-node is installed.
orther problem that i have is the regex in pattern property in mikro-orm.config.ts was wrong because a typo.
If any of the suggested steps didnt solve it for you, simply...
quit yarn watch and yarn dev
run this command from the command line
npx mikro-orm migration:up
now restart watch and dev and it you should be good.
from https://mikro-orm.io/docs/migrations/#migration-class
I also experienced this. And like Fares47 said it's possibly because I passed the username and password in ./mikro-orm.config.ts.
And my solution is simply execute the sql command that generated in ./src/migrations/Migration<NUMBERS>.ts file in postgresql terminal.
Here is the command that I execute in the database,
create table "post" ("id" serial primary key, "created_at" timestamptz(0) not null, "updated_at" timestamptz(0) not null, "title" text not null);
Just like what they suggested in the doc,
A safe approach would be generating the SQL on development server and
saving it into SQL Migration files that are executed manually on the
production server.

Issue Connecting to MongoDB Atlas From Docker App hosted on Google Platform

the issue:
This what happens when I curl the endpoint http://ip/getuser/
UnhandledPromiseRejectionWarning: MongoParseError: URI malformed, cannot be parsed
at parseConnectionString (/app/node_modules/mongodb/lib/core/uri_parser.js:542:21)
at connect (/app/node_modules/mongodb/lib/operations/connect.js:272:3)
at cb (/app/node_modules/mongodb/lib/mongo_client.js:221:5)
at maybePromise (/app/node_modules/mongodb/lib/utils.js:714:3)
at MongoClient.connect (/app/node_modules/mongodb/lib/mongo_client.js:217:10)
at Function.MongoClient.connect (/app/node_modules/mongodb/lib/mongo_client.js:427:22)
at exports.IsCardActivated (/app/routes/index.js:47:45)
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at next (/app/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/app/node_modules/express/lib/router/route.js:112:3)
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing in
side of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (re
jection id: 2)
(node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejectio
ns that are not handled will terminate the Node.js process with a non-zero exit code.
router/getuserbydetails
const MongoClient = require('mongodb').MongoClient;
require('dotenv').config()
function connectUrl() {
return process.env.url;
}
exports.GetUserDetails = async (req, res) => {
....
if (!client) client = await MongoClient.connect(connectUrl(), { useNewUrlParser: true })
const db = client.db(getDatabaseName());
....
};
./index.js
var user= require('./routes/user/index');
app.get('/getuser', user.getuser);
Dockerfile
FROM node:10
ENV NODE_ENV="production"
COPY . /app
WORKDIR /app
RUN npm install
ENV PORT 80
EXPOSE 80
CMD [ "node", "index.js" ]
Google Platform: GCE instance setting:
Note:
firewall:
allow 443, 80
using LB on in front of the application.
This application works fine locally I'm wondering where it might be going wrong.

Mocha tests can't connect to postgres database, using knex

I am trying to implement some integration tests using mocha for functions that interact with a postgres database through knex, in a nodejs express app.
The functions work outside of mocha - I can start the app in node or nodemon, submit requests through Postman, retrieve records from the database, add new records, etc. But when I try to test the code through mocha, I get errors like the following for any functions that try to access the database:
select * from "item" where "user_id" = $1 - relation "item" does not exist
The environment variable for the database connection is set to connect to the right database; when I manually test the app end-to-end, everything works; I get data back from the database.
I've included what I think are the relevant code snippets below: the test script for one of the tests that won't work, the function I'm trying to test, and the modules that that function relies on.
TEST SCRIPT
const Item = require('../db/item');
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
// set up the middleware
chai.use(chaiAsPromised);
var should = require('chai').should()
describe('Item.getByUser', function() {
contex`enter code here`t('With valid id', function() {
const item_id = 1;
const expectedResult = "Canoe";
it('should return items', function() {
return Item
.getByUser(item_id)
.then(items => {
items[0].name.should.equal(expectedResult);
});
});
});
SNIPPET FROM THE ITEM.GETBYUSER FUNCTION:
const knex = require('./connection');
module.exports = {
getByUser: function(id) {
return knex('item').where('user_id', id);
},
SNIPPET FROM THE CONNECTION MODULE:
require('dotenv-safe').config();
const environment = process.env.NODE_ENV || 'development';
const config = require('../knexfile')[environment];
module.exports = require('knex')(config);
SNIPPET FROM THE KNEXFILE MODULE:
module.exports = {
development: {
client: 'pg',
connection: process.env.DATABASE_URL
},
production: {
client: 'pg',
connection: process.env.DATABASE_URL
}
};
The error message I get for the above test is:
1) Item.getByUser
With valid id
should return items:
select * from "item" where "user_id" = $1 - relation "item" does not exist
error: relation "item" does not exist
at Connection.parseE (node_modules\pg\lib\connection.js:567:11)
at Connection.parseMessage (node_modules\pg\lib\connection.js:391:17)
at Socket.<anonymous> (node_modules\pg\lib\connection.js:129:22)
at addChunk (_stream_readable.js:284:12)
at readableAddChunk (_stream_readable.js:265:11)
at Socket.Readable.push (_stream_readable.js:220:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
Okay, it's looking like this was in fact related to the environment variable for the database in some way I can't quite figure out. Although I had the database connection set to 'postgres://localhost/mydatabase' the database actually being used when I tested the db live, including migrating and seeding the database through knex commands, was 'postgres://localhost/username' - a database with the same name as the Owner of 'mydatabase'. But I think the mocha tests were trying to connect to mydatabase, which was still empty at that point, since the migrate and seed affected the the database 'username.'
So, I think this can be closed. I'll try to replicate the problem where I was connected to the wrong db; not sure how that could have happened, as I never intentionally set the connection, or any environment variable to 'postgres://localhost/username'.

Migrating to Meteor 1.7.0.4 : MongoDB : "updating the path ... would create a conflict at ..."

Im using meteor, and im trying to go from meteor 1.6 to 1.7
But im encountering errors im unable to get informations about in my tests :
tests.jpg
I get multiple things like this (some are maybe redondant, unused or obsolete) :
Error: Updating the path 'relationChangeRate' would create a conflict at 'relationChangeRate'
at Function.MongoError.create (C:\Users\fquesselaire\AppData\Local\.meteor\packages\npm-mongo\3.0.11\npm\node_modules\mongodb-core\lib\error.js:45:10)
at toError (C:\Users\fquesselaire\AppData\Local\.meteor\packages\npm-mongo\3.0.11\npm\node_modules\mongodb\lib\utils.js:149:22)
at C:\Users\fquesselaire\AppData\Local\.meteor\packages\npm-mongo\3.0.11\npm\node_modules\mongodb\lib\collection.js:1029:39
at C:\Users\fquesselaire\AppData\Local\.meteor\packages\npm-mongo\3.0.11\npm\node_modules\mongodb-core\lib\connection\pool.js:544:18
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)
not occurring in 1.6.*
I tried upgrade my mongodb to 3.6.6, no effect.
Im also unable to get the entire stack in tests to see what is exactly enforcing.
my .meteor/versions :
255kb:meteor-status#1.5.0
accounts-base#1.4.2
accounts-password#1.5.1
akasha:fs-extra#0.26.3
alanning:roles#1.2.16
aldeed:autoform#6.3.0
aldeed:autoform-bs-button-group-input#2.0.0
aldeed:autoform-select2#3.0.1
aldeed:collection2-core#2.1.2
aldeed:template-extension#4.1.0
allow-deny#1.1.0
arillo:flow-router-helpers#0.5.2
autoupdate#1.4.1
babel-compiler#7.1.1
babel-runtime#1.2.4
base64#1.0.11
binary-heap#1.0.10
blaze#2.3.2
blaze-html-templates#1.1.2
blaze-tools#1.0.10
boilerplate-generator#1.5.0
caching-compiler#1.1.12
caching-html-compiler#1.1.3
callback-hook#1.1.0
check#1.3.1
coffeescript#1.0.17
cultofcoders:mocha#2.4.6
dburles:collection-helpers#1.1.0
dburles:factory#1.1.0
ddp#1.4.0
ddp-client#2.3.3
ddp-common#1.4.0
ddp-rate-limiter#1.0.7
ddp-server#2.2.0
deps#1.0.12
diff-sequence#1.1.0
dynamic-import#0.4.1
ecmascript#0.11.1
ecmascript-runtime#0.7.0
ecmascript-runtime-client#0.7.2
ecmascript-runtime-server#0.7.1
ejson#1.1.0
email#1.2.3
es5-shim#4.8.0
fourseven:scss#4.9.0
geojson-utils#1.0.10
hot-code-push#1.0.4
html-tools#1.0.11
htmljs#1.0.11
http#1.4.1
id-map#1.1.0
idmontie:migrations#1.0.3
jquery#1.11.11
kadira:blaze-layout#2.3.0
kadira:flow-router#2.12.1
lai:collection-extensions#0.2.1_1
launch-screen#1.1.1
livedata#1.0.18
lmieulet:meteor-coverage#1.1.4
localstorage#1.2.0
logging#1.1.20
matb33:collection-hooks#0.8.4
meteor#1.9.2
meteor-base#1.4.0
meteorhacks:picker#1.0.3
meteortesting:browser-tests#1.0.0
meteortesting:mocha#1.0.0
minifier-css#1.3.1
minifier-js#2.3.5
minimongo#1.4.4
mobile-experience#1.0.5
mobile-status-bar#1.0.14
modern-browsers#0.1.2
modules#0.12.2
modules-runtime#0.10.2
momentjs:moment#2.22.2
mongo#1.5.1
mongo-dev-server#1.1.0
mongo-id#1.0.7
mouse0270:bootstrap-notify#3.1.3
natestrauser:select2#4.0.3
npm-bcrypt#0.9.3
npm-mongo#3.0.11
observe-sequence#1.0.16
ordered-dict#1.1.0
ostrio:cookies#2.3.0
ostrio:files#1.10.1
practicalmeteor:chai#2.1.0_1
practicalmeteor:loglevel#1.2.0_2
practicalmeteor:mocha-core#1.0.1
practicalmeteor:sinon#1.14.1_2
promise#0.11.1
raix:eventemitter#0.1.3
random#1.1.0
rate-limit#1.0.9
reactive-dict#1.2.1
reactive-var#1.0.11
reload#1.2.0
retry#1.1.0
rocketchat:streamer#0.5.0
routepolicy#1.0.13
service-configuration#1.0.11
session#1.1.8
sewdn:collection-behaviours#0.3.0
sha#1.0.9
shell-server#0.3.1
socket-stream-client#0.2.2
softwarerero:accounts-t9n#1.3.11
spacebars#1.0.15
spacebars-compiler#1.1.3
srp#1.0.12
standard-minifier-css#1.4.1
standard-minifier-js#2.3.4
templating#1.3.2
templating-compiler#1.3.3
templating-runtime#1.3.2
templating-tools#1.1.2
tmeasday:check-npm-versions#0.3.2
tmeasday:test-reporter-helpers#0.2.1
tracker#1.2.0
ui#1.0.13
underscore#1.0.10
url#1.2.0
useraccounts:bootstrap#1.14.2
useraccounts:core#1.14.2
useraccounts:flow-routing#1.14.2
webapp#1.6.2
webapp-hashing#1.0.9
zimme:active-route#2.3.2
my node packages :
"dependencies": {
"#babel/runtime": "^7.0.0-beta.54",
"#mdi/font": "^2.5.94",
"babel-runtime": "^6.26.0",
"bcrypt": "^3.0.0",
"bootstrap": "^3.3.7",
"bootstrap-material-design": "^0.5.10",
"bootstrap-slider": "^10.0.2",
"bootstrap-toggle": "^2.2.2",
"clone": "^2.1.1",
"csv-parse": "^2.5.0",
"d3": "^5.5.0",
"file-saver": "^1.3.8",
"fs-extra": "^3.0.1",
"gm": "^1.23.0",
"jquery": "^2.2.4",
"jsondiffpatch": "^0.3.11",
"lodash": "^4.17.10",
"meteor-node-stubs": "^0.4.1",
"mkdirp": "^0.5.1",
"object-path": "^0.11.4",
"popper.js": "^1.14.3",
"select2": "^4.0.4",
"select2-bootstrap-theme": "^0.1.0-beta.10",
"simpl-schema": "^1.5.3",
"uuid": "^3.3.2",
"xmldoc": "^1.1.0",
"zip-local": "^0.3.4"
},
"devDependencies": {
"chromedriver": "^2.40.0",
"gulp": "^3.9.1",
"selenium-webdriver": "^3.6.0"
}
if you have any clue about what is going on ?
i can give more informations about what's happening in the app, but right now a simple explain about what this error mean would be awesome already. as i said, this error only append in 1.7.
EDIT: forget to say that my test throw this on WORKING code.
Features are working well, but not the tests.
EDIT²:
This method is the one that update the collection projectSettings.
_duplicateProjectSettings(newSession) {
const settings = this.session.projectSettings();
delete settings._id;
settings.sessionId = newSession._id;
const newSettings = newSession.projectSettings();
ProjectSettings.update(newSettings._id, { $set: settings });
}
relationChangeRate is a simpl-schema field of projectSettings collection as it (i use collection2-core) :
relationChangeRate: {
type: Number,
allowedValues: _.values(RelationRates),
defaultValue: 0.0
}
projectSettings extends mongo.collection, but in this case, update method is not override.
The code seams correct to me, as the _id is well removed and set to the new object before update request. but maybe im wrong ?
EDIT³:
ProjectSettings is a collection-helper:
Here is the code :
Sessions.helpers({
[...]
projectSettings() {
const conds = { sessionId: this._id };
return ProjectSettings.findOne(conds);
},
[...]
A collection helper basically add a method on each document from this collection. It means that any session object will have this method. In a collection helper, "this" refer to the current collection object.
so should be good ?
_duplicateProjectSettings could be write like this:
_duplicateProjectSettings(newSession) {
// const settings = this.session.projectSettings();
const settings = ProjectSettings.findOne({ sessionId: this.session._id });
delete settings._id;
settings.sessionId = newSession._id;
// const newSettings = newSession.projectSettings();
const newSettings = ProjectSettings.findOne({ sessionId: newSession._id });
ProjectSettings.update(newSettings._id, { $set: settings });
}
(I tried it too, same result)
Running this from shell worked for me... not the best solution. I had the problem when I tried to login with accounts-password package.
$ meteor mongo
meteor:PRIMARY> db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )
Ok,
This is an half-answer but
After some extended search i figured that i had a test script that reset MONGO_URL as follow :
set MONGO_URL=
set TEST_BROWSER_DRIVER=chrome
set TEST_WATCH=1
set TEST_CLIENT=0
set TEST_SERVER=1
meteor test -p 3100 --driver-package=cultofcoders:mocha %*
after figuring that i launched the tests on my local dev db, and tests passed (smashing my db by the way lol). So, it means it could be version related, or test-conditions related.
I am not able to print the version of mongodb used for tests, so i don't know the tests conditions exactly.
All i know is so :
Meteor "normal run" Mongo version : 3.6.4
My local Mongo version : 3.6.6